# This file is the entry point to configure your own services.
parameters:
    app.project_dir: '%kernel.project_dir%'
    # Centralized data dir for this app: <repo-root>/data/product-ai-automation by
    # default (kernel.project_dir is .../product-ai-automation/backend). Override with
    # APP_DATA_DIR. Persistent data (DB, generated images/videos) lives here; it's the
    # one folder the CI never deploys (rsync --exclude=data), so it survives deploys.
    app.default_data_dir: '%kernel.project_dir%/../../data/product-ai-automation'
    app.data_dir: '%env(default:app.default_data_dir:APP_DATA_DIR)%'

services:
    _defaults:
        autowire: true
        autoconfigure: true

    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Message/'
            - '../src/Dto/'
            - '../src/Kernel.php'

    # Structured JSON log formatter consumed by the Digt observability stack.
    app.monolog.json_formatter:
        class: Monolog\Formatter\JsonFormatter
        arguments:
            $batchMode: !php/const Monolog\Formatter\JsonFormatter::BATCH_MODE_NEWLINES
            $appendNewline: true

    # Per-channel loggers so services can request a specific monolog channel by name.
    Psr\Log\LoggerInterface $ergonodeLogger: '@monolog.logger.ergonode'
    Psr\Log\LoggerInterface $vertexLogger: '@monolog.logger.vertex'
    Psr\Log\LoggerInterface $imageLogger: '@monolog.logger.image'
    Psr\Log\LoggerInterface $costLogger: '@monolog.logger.cost'
    Psr\Log\LoggerInterface $pipelineLogger: '@monolog.logger.pipeline'
    Psr\Log\LoggerInterface $auditLogger: '@monolog.logger.audit'

    # Real-only runtime: the pipeline talks exclusively to the live services.
    # Vertex + segmentation are bound directly; Ergonode is built from the (admin-
    # editable) connection config via the factory; Slack posts to the webhook.
    # Unconfigured services fail loudly rather than silently falling back to a mock.
    App\Ai\AiProviderInterface: '@App\Ai\Vertex\VertexAiProvider'
    App\Ai\SegmentationProviderInterface: '@App\Ai\Vertex\VertexSegmentationProvider'
    App\Ergonode\ErgonodeClientInterface: '@App\Ergonode\DelegatingErgonodeClient'
    App\Slack\SlackNotifierInterface: '@App\Slack\WebhookSlackNotifier'

# Tests run on deterministic in-memory doubles (the Mock* classes are kept solely
# as test fixtures — never wired at runtime).
when@test:
    parameters:
        # Isolate test artifacts: the pipeline writes generated media with the real
        # ImagePipeline/VideoPipeline (fed mock bytes), so point the data dir at a
        # throwaway, git-ignored location — never the shared centralized data/ dir.
        app.data_dir: '%kernel.project_dir%/var/test-data'
    services:
        App\Ai\AiProviderInterface: '@App\Ai\Mock\MockAiProvider'
        App\Ai\SegmentationProviderInterface: '@App\Ai\Mock\MockSegmentationProvider'
        App\Ergonode\ErgonodeClientInterface: '@App\Ergonode\Mock\MockErgonodeClient'
        App\Slack\SlackNotifierInterface: '@App\Slack\MockSlackNotifier'
