"""Optimization context bundle for the pipeline.

:class:`OptimizationContext` groups the four project-level
dependencies that nearly every pipeline function needs:
*project_root*, *test_cfg*, *ai_client*, and *plugin*.
Passing a single frozen object instead of four loose parameters
reduces function signatures and eliminates accidental mismatches.
"""

from __future__ import annotations

from typing import TYPE_CHECKING

import attrs

if TYPE_CHECKING:
    from pathlib import Path

    from codeflash_core import AIClient

    from ..testing.models import TestConfig
    from ._plugin import PythonPlugin


@attrs.frozen
class OptimizationContext:
    """Immutable bundle of project-level optimization dependencies.

    Created once per optimization run and threaded through the
    pipeline.  Individual functions destructure only the fields
    they need (``ctx.project_root``, ``ctx.ai_client``, etc.).
    """

    project_root: Path
    test_cfg: TestConfig
    ai_client: AIClient
    plugin: PythonPlugin
