"""Shared fixtures: the mock workshop scenario every pin is hand-checked
against (see test_value_math for the arithmetic). Also makes diaglib
importable without the study venv active (normal setup is
``pip install -e ".[dev]"`` into the study-local ``.venv/``)."""

import pathlib
import sys
from datetime import datetime

import pytest

sys.path.insert(0, str(pathlib.Path(__file__).resolve().parent.parent))

from diaglib import OperationalBaseline, build_scores, load_config  # noqa: E402

CONFIGS = pathlib.Path(__file__).resolve().parent.parent / "configs"

SCORED_AT = datetime(2026, 7, 19, 9, 0)

#: The seed capability profile: data_readiness is the unique weakest
#: foundation (level 2), so the binding constraint is a single competency.
SEED_SCORES = {
    "automation_ai_strategy": (2, "AI driven by board pressure; no written thesis"),
    "value_realization": (2, "Business cases pre-investment only"),
    "executive_alignment": (3, "COO owns CX AI; steering meets quarterly"),
    "process_discovery": (3, "Top 10 call reasons mapped with volumes"),
    "data_readiness": (2, "KB stale; interaction data siloed in recordings"),
    "technical_architecture": (3, "CCaaS APIs available; shared integration layer WIP"),
    "use_case_prioritization": (3, "Scored backlog reviewed monthly"),
    "delivery_capability": (3, "Two bots in production via SI partner"),
    "talent_and_skills": (2, "One conversation designer, contractor"),
    "ai_operations": (2, "Containment eyeballed weekly, no drift alerts"),
    "change_adoption": (3, "Agent champions for copilot rollout"),
    "governance_and_risk": (3, "AI policy signed; review board for voice bots"),
}


@pytest.fixture(scope="session")
def config():
    return load_config("contact_center", CONFIGS)


@pytest.fixture(scope="session")
def stub_config():
    return load_config("financial_services", CONFIGS)


@pytest.fixture()
def baseline():
    return OperationalBaseline(
        annual_contact_volume=1_200_000,
        blended_cost_per_contact=6.50,
        agent_headcount=450,
        annual_attrition_rate=0.30,
        current_containment_rate=0.20,
        average_handle_time_seconds=420,
        field_confidence={
            "annual_contact_volume": "known",
            "blended_cost_per_contact": "estimated",
            "agent_headcount": "known",
            "annual_attrition_rate": "estimated",
            "current_containment_rate": "estimated",
            "average_handle_time_seconds": "known",
        },
    )


@pytest.fixture()
def scores(config):
    return build_scores(config, SEED_SCORES, scored_at=SCORED_AT)
