from pathlib import Path
import yaml
from agent_framework.guardrails.config_loader import load_guardrails_config


def test_original_default_guardrails_estao_ativos_no_pipeline_framework():
    cfg=yaml.safe_load(Path('config/guardrails.yaml').read_text())
    inputs={x['code'] for x in cfg['input'] if x.get('enabled')}
    outputs={x['code'] for x in cfg['output'] if x.get('enabled')}
    assert {'MSK','INPUT_SIZE','PINJ','COER'} <= inputs
    assert {'TIM_OOS','TIM_AOFERTA','TIM_REVPREC','CMP'} <= outputs
    assert 'OOS' not in outputs and 'AOFERTA' not in outputs and 'REVPREC' not in outputs


def test_framework_loader_instancia_coer_e_preserva_fraseologia_tim_desabilitada():
    loaded=load_guardrails_config('config/guardrails.yaml')
    codes={getattr(x,'code','') for rails in (loaded.input_rails, loaded.output_rails, loaded.retrieval_rails, loaded.tool_rails) for x in rails}
    assert 'COER' in codes
    assert 'FRASEOLOGIA' not in codes
    assert 'TIM_FRASEOLOGIA' not in codes  # permanece comentado/desabilitado como no source de entrada
