# Daily MX tagging for the FMCSA carrier audience. Resolves the MX records of
# carrier email domains that don't yet have an mx_provider and stores the
# receiving operator (google/microsoft/proofpoint/... or an "mx:<root>" label for
# everything else). The trucking campaign builder uses mx_provider to EXCLUDE the
# big + consumer mailbox operators during warmup (Google/MS/Yahoo/iCloud/... all
# throttle or complaint-block a cold IP) and to per-operator-throttle the rest.
#
# WHY a cron: mx_provider was previously only tagged by hand, so the untagged
# (NULL) backlog never drained (~316k sendable carriers on 2026-06-20) and every
# new FMCSA census import landed untagged. Untagged carriers are KEPT in the warmup
# pool (anti-starvation), so an untagged Google/Yahoo domain can slip the exclusion
# until it's tagged. Running daily keeps the audience classified so the warmup
# exclusion stays effective. Idempotent + bounded: only resolves domains where
# mx_provider IS NULL, capped at --limit-domains/run.
#
# Runs 05:45 UTC, before the 06:10 reputation monitor / 06:20 DMARC / 06:30 scrub
# and well before the 08:00 trucking builder, so the day's send sees fresh tags.
# --only-unsent prioritizes carriers the builder will actually mail.
45 5 * * * deploy cd /opt/performancewest && docker compose exec -T workers python3 -m scripts.mx_tag_carriers --only-unsent --limit-domains 20000 >> /var/log/pw-mx-tag.log 2>&1
