feat(mail): instrument protocol syncs and log destructive IMAP ops #374

Merged
KofTwentyTwo merged 1 commits from story/obs-5-mail-observability into dev 2026-08-01 00:19:17 +00:00
1 Commits
Author SHA1 Message Date
James Maes 6982970172 feat(mail): instrument protocol syncs and log destructive IMAP ops
Wrap IMAP/JMAP folder and message sync in tracing spans keyed by account
and folder, logging completion counts (fetched/oversized/skipped) so a
sync run's outcome is visible without a debugger. SMTP send attempts and
their outcome are logged with the recipient COUNT only, never addresses.

Every destructive IMAP mutation (MOVE, DELETE/UID-scoped EXPUNGE) is
logged with its UID set and the UIDVALIDITY guard's pass/fail result
BEFORE the command reaches the server, so an audit trail exists even
when the guard then refuses to act. JMAP mirrors the same pre-logging
for its Email/set move/destroy, keyed by the JMAP object id instead of
a UID (JMAP has no UIDVALIDITY-equivalent to guard).

Refs #361
2026-07-31 19:13:29 -05:00