"""ASV benchmarks for TDD Issue #570 — session create CLI throughput.

Measures the performance of the session create CLI command path to establish
a baseline before and after the DI bug fix.  Uses a mocked service so the
benchmark isolates CLI/rendering overhead from database I/O.
"""

from __future__ import annotations

from unittest.mock import MagicMock

from benchmarks._session_bench_common import mock_session, runner
from cleveragents.cli.commands import session as session_mod
from cleveragents.cli.commands.session import app as session_app


class TDDSessionCreateDISuite:
    """Benchmark session create command throughput (TDD issue #570 baseline)."""

    def setup(self) -> None:
        self._svc = MagicMock()
        self._svc.create.return_value = mock_session()
        session_mod._service = self._svc

    def teardown(self) -> None:
        session_mod._service = None

    def time_create_default(self) -> None:
        """Benchmark create with defaults."""
        runner.invoke(session_app, ["create"])

    def time_create_with_actor(self) -> None:
        """Benchmark create with actor flag."""
        runner.invoke(session_app, ["create", "--actor", "openai/gpt-4"])

    def time_create_json(self) -> None:
        """Benchmark create with JSON format."""
        runner.invoke(session_app, ["create", "--format", "json"])
