"""Shared helpers for TDD session DI ASV benchmarks.

Extracted from ``tdd_session_create_di_bench.py`` and
``tdd_session_list_di_bench.py`` to eliminate duplication (review finding F9).
"""

from __future__ import annotations

import sys
from datetime import datetime
from pathlib import Path

# Ensure the local *source* tree is importable even when ASV has an
# older build of the package installed.  This is a permanent mutation of
# ``sys.path`` — acceptable because ASV runs each benchmark suite in its
# own isolated process.
_SRC = str(Path(__file__).resolve().parents[1] / "src")
if _SRC not in sys.path:
    sys.path.insert(0, _SRC)

from typer.testing import CliRunner  # noqa: E402
from ulid import ULID  # noqa: E402

from cleveragents.domain.models.core.session import (  # noqa: E402
    Session,
    SessionTokenUsage,
)

runner = CliRunner()


def mock_session(
    session_id: str | None = None,
    actor_name: str | None = None,
) -> Session:
    """Create a ``Session`` instance with sensible defaults for benchmarks."""
    return Session(
        session_id=session_id or str(ULID()),
        actor_name=actor_name,
        namespace="local",
        messages=[],
        token_usage=SessionTokenUsage(),
        created_at=datetime.now(),
        updated_at=datetime.now(),
    )
