"""Pinned 1.11 config API contract; CPU only, no model/weight instantiation."""
import pytest
from pallet.mask_model_improvement_retry import scheduler_compatibility


def test_1_11_scheduler_field_validates_without_changing_schedule():
    from rfdetr.config import SegmentationTrainConfig
    kwargs = scheduler_compatibility(dict(dataset_dir='not-loaded', output_dir='not-written',
        epochs=46, batch_size=2, grad_accum_steps=4, lr=1e-4, lr_encoder=1e-5,
        lr_drop=1000, run_test=False, use_ema=True, early_stopping=False))
    config = SegmentationTrainConfig(**kwargs)
    assert config.lr_scheduler_kwargs['lr_drop'] == 1000
    assert config.lr_scheduler == 'step'
    assert config.lr == 1e-4 and config.lr_encoder == 1e-5
    assert config.batch_size * config.grad_accum_steps == 8
    assert not config.run_test


def test_duplicate_scheduler_scope_is_rejected():
    with pytest.raises(ValueError, match='duplicate'):
        scheduler_compatibility(dict(lr_drop=1000, lr_scheduler_kwargs=dict(lr_drop=100)))
