Remove apps/alerts/tasks.py
Problem
apps/alerts/tasks.py implements a legacy Celery-based pipeline that duplicates what apps/orchestration/ does properly. It violates the project’s boundary rule (“Only apps.orchestration advances the pipeline”) by running all 4 stages from inside apps.alerts, bypassing PipelineOrchestrator entirely.
Consequences of the current state:
- No
PipelineRun/StageExecutionrecords — runs through this path are invisible - No
trace_id/run_idcorrelation - Retry logic reimplemented ad-hoc via Celery decorators instead of the orchestrator’s state machine
notify_channelstask hardcodes its own driver lookup, severity mapping, and message formatting
Current test coverage: 12%.
Decision
Delete apps/alerts/tasks.py and route the async webhook path through apps.orchestration.tasks.run_pipeline_task.
Changes
-
apps/alerts/views.py— Replaceapps.alerts.tasks.orchestrate_eventimport withapps.orchestration.tasks.run_pipeline_task. Adapt.delay()call to matchrun_pipeline_task’s signature (payload,source, etc.). Keep the 202 async response shape. -
apps/alerts/tasks.py— Delete entirely. -
apps/alerts/_tests/test_tasks.py— Delete entirely. -
apps/alerts/_tests/views/test_webhook.py— Update mocks referencingapps.alerts.tasks.orchestrate_eventto referenceapps.orchestration.tasks.run_pipeline_task. -
docs/Architecture.md— Update references to old task names if they point toapps.alerts.tasks.
What stays the same
- Async/sync split in
views.py(Celery available → 202; Celery down → sync fallback) ENABLE_CELERY_ORCHESTRATIONenv varCELERY_TASK_ALWAYS_EAGERcheck- Sync fallback calls
AlertOrchestrator.process_webhook()directly