""" Everything that happens "when its time comes", run from one place so a single timer drives it: queued and scheduled sends, and automations (sequences, recurring and date-based sends). See docs/blueprint/adr/0004. """ from __future__ import annotations from datetime import datetime from backend import automations, delivery, sending def run_due(now: datetime | None = None, budget_seconds: float = 240) -> dict: # Automations first, so the campaigns they make are picked up in the same pass. made = automations.run_due(now) sends = sending.run_due(now, budget_seconds) return {"automations": made, "sends": sends, "delivery": delivery.run_due(now)}