"""Focused orchestration contracts for study execution."""

from __future__ import annotations

from unittest.mock import Mock

import pytest

from obliteratus import runner
from obliteratus.config import DatasetConfig, ModelConfig, StrategyConfig, StudyConfig


def test_run_study_passes_configured_quantization_to_loader(tmp_path, monkeypatch):
    config = StudyConfig(
        model=ModelConfig(name="fixture", quantization="4bit"),
        dataset=DatasetConfig(name="fixture"),
        strategies=[StrategyConfig(name="layer_removal")],
        output_dir=str(tmp_path),
    )
    load_model = Mock(side_effect=RuntimeError("stop after loader boundary"))
    monkeypatch.setattr(runner, "load_model", load_model)

    with pytest.raises(RuntimeError, match="stop after loader boundary"):
        runner.run_study(config)

    assert load_model.call_args.kwargs["quantization"] == "4bit"
