from slot_policy import AdaptivePercentPolicy


def test_adaptive_percent_policy_refines_step_size_deterministically() -> None:
    policy = AdaptivePercentPolicy(step_percent=10.0, min_step_percent=2.5, split_threshold=3)

    policy.note_slot_use(slot_id=4, hit_count=3)

    assert policy.step_percent == 5.0
    assert policy.compute_slot_id(last_input=100.0, current_input=120.0) == 4


def test_adaptive_percent_policy_respects_minimum_step_size() -> None:
    policy = AdaptivePercentPolicy(step_percent=10.0, min_step_percent=2.5, split_threshold=1)

    for _ in range(10):
        policy.note_slot_use(slot_id=1, hit_count=1)

    assert policy.step_percent == 2.5
