"""The words a background run's row is written with — the `job_runs` table's status and trigger. One source for the literals: the scheduler writes them, the startup sweep rewrites `running`, the model's CHECK constraints are built from these sets, and the dashboard reads them back. A run's status is never typed as a string anywhere else (the download pipeline's `cancelled`/`canceled` drift, `downloads/status.py`, is why). """ from enum import StrEnum class RunStatus(StrEnum): RUNNING = "running" OK = "ok" ERROR = "error" # Sync was paused: the run was due and deliberately did nothing. SKIPPED = "skipped" # The process stopped while the run was going (a deploy, a crash): set at the next startup, so a # row never claims to be running in a process that no longer exists. INTERRUPTED = "interrupted" class RunTrigger(StrEnum): # The run's interval came round. SCHEDULED = "scheduled" # An admin pressed "run now" (or "run all"). MANUAL = "manual" # A user's own action started work on one target (a channel's full history), outside the # recurring jobs. AD_HOC = "ad_hoc" def sql_in(values: type[StrEnum]) -> str: """`'a', 'b'` — the IN-list a CHECK constraint names these values with.""" return ", ".join(f"'{v.value}'" for v in values)