fix(heartbeat): delete the Sent copy of the roundtrip probe

Merged
UR
2d ago
+149-31

The roundtrip probe deleted only the inbox delivery copy, leaving one Sent message behind per probe in heartbeat@meowlabs.id.

The send files a copy in Sent (the message object the submission moves there) and delivery files a second, distinct copy in the inbox, so the probe now deletes both: the Sent copy right after send returns (before waiting on delivery, so a failed delivery leaves nothing behind), then the inbox copy once it arrives.

The Sent lookup lists the newest Sent messages and matches the subject client-side instead of a full-text search, which lags a message filed seconds ago. Only subjects carrying this probe iris-heartbeat- token are destroyed; no other mail is touched.

Fake JMAP now models the two distinct copies (msg-sent, msg-1) and the happy-path test asserts both are destroyed.

Local verification: fmt clean, clippy --all-targets --all-features -- -D warnings clean, cargo test --all-targets 327 passed 0 failed (8 heartbeat tests, incl. roundtrip_happy_path_delivers_and_deletes).

Summary by CodeRabbit

  • Bug Fixes
    • Heartbeat checks now remove temporary messages from both Sent and Inbox, reducing leftover probe messages.
    • Cleanup handles separate copies of the same message without attempting to delete an already-removed copy.
    • If a sent message does not appear immediately, cleanup retries before reporting a failure.