mail_trash on JMAP: apply, undo and mirror effect #193
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#193
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 items 2 to 4 for JMAP.
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
unsupportedrefusal from the IMAP trash issue. Resolve exactly one mailbox with the trash role; zero or several isunsupported. Send oneEmail/setwithifInStatethat replaces every mailbox membership of each message with Trash. Record the priormailboxIdsset of each message as the inverse.not_foundand change nothing.Notes from the IMAP issue (#192, PRs #199 and #200)
trashaction that returns an inverse. Reuse both; add no second path.trashwithunsupported, and a test pins that. Replace the test.Acceptance criteria
Email/setwithifInState; a message in two mailboxes ends in Trash only; the inverse holds both prior memberships.not_found.unsupported.make checkpasses.Out of scope
Any change to the tool, the cap or the schema.
Blocked by
⏸ SVD architect gate: dev/mail-mind-mcp#193 mail-trash-on-jmap-apply-undo-and-mirror-effect
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:
20261112T195614Z-8b46fe9fHeld because: CLEAN but 5 open risk(s) (2 verification · 3 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
make test-stalwartafter dispatch and confirm that test_trash_and_its_undo passes rather than being refused as unsupported. [verification]05ef02c, runmake install && uv run python3 -m pytest -q -m "not integration" tests/test_jmap.py tests/test_store.py tests/test_actions.pybefore editing, then confirmmake checkpasses after the change with only test_trash_is_unsupported_on_jmap replaced. [verification]Change: Extend the single trash settle path rather than adding a second one, using the same extraction #200 did for delete_uids → _delete_uid_rows (store.py:1451-1483).
store.py: extract the body of delete_sources (store.py:2137-2167) into _delete_source_rows(conn, account, source_ids, at). Give finish_trash (store.py:3389) a
source_ids: Iterable[str] = ()keyword and delete those rows in the same transaction. This keeps the action result, the row deletes, the changes 'del' rows with source_id, and the peer del events in one transaction. Deleting through _delete_uid_rows instead would log the JMAP change without source_id, which gives the wrong public id.source.py _settle_trash (159-177): branch on
"source_ids" in inverse, the same test server._outcome uses at server.py:1522. A JMAP inverse is always applied, passes uids=[] and source_ids=inverse["dropped"]. The IMAP branch is unchanged. When finish_trash returns False, return and log the state the store holds (store.get_action), not the state this call meant to write.jmap.py: remove the refusal at :491-492 and dispatch trash after the read-only check. Add _trash, mirroring _move (854-880):
Add _undo_trash. It reads with a tolerant Email/get and skips ids that were destroyed or are no longer in Trash. It restores the prior memberships that still exist, removes Trash only if it was not a prior membership, and raises not_found when no patch remains. It sends one ifInState _set, then calls _mirror (a no-op for dropped rows; the next pass re-adds unknown ids).
ADR 0006 §10: add one sub-bullet line pointing to ADR 0013.
Files:
src/mail_mind_mcp/jmap.py·src/mail_mind_mcp/source.py·src/mail_mind_mcp/store.py·tests/test_jmap.py·tests/test_store.py·tests/integration/test_stalwart.py·docs/adr/0006-pluggable-mail-sources.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-12-mail-trash-on-jmap-apply-undo-and-mirror-effect.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-jmap-apply-undo-and-mirror-effect.md✅ SVD architect gate: dev/mail-mind-mcp#193 mail-trash-on-jmap-apply-undo-and-mirror-effect
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:
20261112T195614Z-8b46fe9fFiles:
src/mail_mind_mcp/jmap.py·src/mail_mind_mcp/source.py·src/mail_mind_mcp/store.py·tests/test_jmap.py·tests/test_store.py·tests/integration/test_stalwart.pyWrite-set divergence: present table wins. 0 sourceHashes vs 17-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-trash-on-jmap-apply-undo-and-mirror-effect.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-12-mail-trash-on-jmap-apply-undo-and-mirror-effect.mdspec-verify-dispatch Half B for dev/mail-mind-mcp#193 mail-trash-on-jmap-apply-undo-and-mirror-effect completed integration verify.
039810b700make test-stalwartafter merge (spec Open Risk 4).codex-svd ship --run-id 20261112T201217Z-e443c69e --confirm-merge)