from __future__ import annotations

from django.apps import AppConfig
from django.utils.module_loading import autodiscover_modules


class AutomationConfig(AppConfig):
    default_auto_field = "django.db.models.BigAutoField"
    name = "simorgh.apps.automation"
    label = "automation"
    verbose_name = "Automation Engine"

    def ready(self) -> None:
        # Register automation permissions in the IAM registry.
        from simorgh.apps.automation import permissions  # noqa: F401

        # Each module may expose an ``automations.py`` that registers actions.
        autodiscover_modules("automations")

        # Wire Event Bus subscriptions so triggered rules are dispatched.
        from simorgh.apps.automation import events  # noqa: F401

        # Register agent orchestration Celery tasks.
        from simorgh.apps.automation import agent_tasks  # noqa: F401
