feat: heartbeat endpoint with real-path Stalwart JMAP probe

Merged
UR
2d ago
+833-1

Heartbeat endpoint with real-path Stalwart JMAP probe

GET /heartbeat answers 200 only when the database and the Stalwart JMAP path are both healthy, so an external monitor can alert on the status code alone. Per-component JSON (name, status, latency_ms), no sensitive info.

  • database: existing iris_database::health_check, 5s timeout.
  • stalwart_jmap: real login via JmapClient::login (plain GET /jmap/session, mints no app password) plus a real management read (x:Domain/get). Fails closed with 503 while the admin credential is unset, matching the alias endpoints.
  • mail_roundtrip (only with ?roundtrip=true): sends a test message from a dedicated heartbeat mailbox to itself, waits for delivery, then deletes it. Unconfigured it reports disabled and never fails the endpoint; configured but not requested it reports skipped. 60s budget, 2s poll interval.

Alerting v1 is the 503 status for an external monitor plus one structured tracing::warn per failed check. No push notification built in.

Verified locally: fmt, clippy -D warnings, cargo test --all-targets 327 passed, 0 failed, including failure-detection tests (admin unset / Stalwart 401 / unreachable / DB down / roundtrip failure all yield 503) and a roundtrip happy-path test.

Deploy note: needs a dedicated heartbeat mailbox plus IRIS_HEARTBEAT_MAILBOX_USER / IRIS_HEARTBEAT_MAILBOX_PASSWORD in the VPS .env before roundtrip is live; without them the endpoint still reports database + JMAP health.