caelum0x 9eca01d320 feat: near-real-time delivered/bounced/complained events from OCI Email Delivery logs
Resend parity for delivery outcomes. OCI Email Delivery writes one
OutboundRelayed service-log record per recipient (relay, bounce, complaint);
a new one-minute BullMQ job reads them through the OCI Logging Search API
(no Connector Hub push: Notifications HTTPS caps at 60 msgs/min per topic)
and feeds Delivery / Bounce / Complaint events through processEmailEvent.

- Provider: ensureDeliveryLogs (idempotent, cached) creates the
  "scribase-mail" log group and emaildelivery service logs
  (outboundrelayed, outboundaccepted) per ACTIVE email domain;
  listDeliveryEvents runs a compartment-scoped Logging Search
  (oci-logging / oci-loggingsearch 2.142.2).
- Job provider-delivery-log-poll: appSetting cursor with 10 min overlap,
  1 day max lookback, ProcessedProviderLogEvent dedupe table (pruned after
  3 days), truncation-safe cursor, enables logs on verified domains with a
  30 min back-off on failures. DELIVERY_LOG_POLL_CRON default every minute.
- relay -> DELIVERED, bounce hard/soft -> Permanent/Transient with category,
  code and SMTP status, complaint -> COMPLAINED; open/click/unsubscribe ignored.
- processEmailEvent skips a Delivery/Bounce/Complaint already recorded for
  the same recipient (log poll vs suppression poll), counts usage once per
  email and only adds hardBounced when a soft bounce turns permanent.
- Domain create/verify call ensureDeliveryLogs without failing on errors.
- Docs: IAM policy (manage log-groups, read log-content), env vars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 03:18:55 +03:00
..