"""Translate a case's期望 (Expectation) into implicit评估规则.

期望描述"想要什么"，评估规则是"怎么判定"——期望派生的隐式规则与显式规则
叠加生效（CONTEXT.md）。此翻译是纯逻辑，独立于规则执行与持久化，便于单测。
"""

from agenteval.models import EvalRuleConfig, Expectation


def derive_implicit_rules(expectation: Expectation) -> list[EvalRuleConfig]:
    """Build the implicit rule configs a case's expectation implies."""
    rules: list[EvalRuleConfig] = []
    if expectation.response_time_max_ms:
        rules.append(
            EvalRuleConfig(
                type="response_time",
                params={"max_ms": expectation.response_time_max_ms},
            )
        )
    if expectation.keywords_include or expectation.keywords_exclude:
        rules.append(
            EvalRuleConfig(
                type="keyword_match",
                params={
                    "keywords": expectation.keywords_include,
                    "exclude_keywords": expectation.keywords_exclude,
                },
            )
        )
    return rules
