from pathlib import Path
import yaml


def test_invoice_explanation_declares_configurable_semantic_classifier():
    root = Path(__file__).resolve().parents[2]
    data = yaml.safe_load((root / "workflows" / "invoice_explanation.v2.yaml").read_text(encoding="utf-8"))
    formatar = next(node for node in data["nodes"] if node["id"] == "formatar")
    expected = formatar["pause"]["expected_input"]
    assert expected["allowed_values"] == ["SIM", "NAO", "CONTINUAR"]
    classifier = expected["semantic_classifier"]
    assert classifier["enabled"] is True
    assert classifier["include_relevant_context"] is True
    assert "{{ relevant_conversation_context }}" in classifier["prompt"]
    assert "{{ allowed_values }}" in classifier["prompt"]
    assert "R$ 275,00" in classifier["prompt"]
    assert "=> CONTINUAR" in classifier["prompt"]
    assert classifier["option_actions"]["CONTINUAR"]["action"] == "contextual_reentry"
