| from unittest.mock import Mock | |
| from app.services.risk_service import evaluate_intent, evaluate_healing_decision | |
| from agentic_reliability_framework.core.governance.intents import ProvisionResourceIntent, ResourceType | |
| from agentic_reliability_framework.core.models.event import ReliabilityEvent | |
| from agentic_reliability_framework.core.governance.policy_engine import PolicyEngine | |
| def test_evaluate_intent(): | |
| engine = Mock() | |
| engine.calculate_risk.return_value = (0.5, "explanation", {"a": 1}) | |
| intent = ProvisionResourceIntent( | |
| resource_type=ResourceType.VM, | |
| region="eastus", | |
| size="Standard_D2s_v3", | |
| requester="alice", | |
| environment="dev" | |
| ) | |
| result = evaluate_intent( | |
| engine, | |
| intent, | |
| cost_estimate=100.0, | |
| policy_violations=[]) | |
| assert result["risk_score"] == 0.5 | |
| assert result["explanation"] == "explanation" | |
| engine.calculate_risk.assert_called_once() | |
| def test_evaluate_healing_decision(): | |
| event = ReliabilityEvent( | |
| component="test", | |
| latency_p99=600, | |
| error_rate=0.2, | |
| service_mesh="default" | |
| ) | |
| policy_engine = PolicyEngine() | |
| # Temporarily disable decision engine to get raw actions | |
| policy_engine.use_decision_engine = False | |
| result = evaluate_healing_decision(event, policy_engine) | |
| assert "selected_action" in result | |
| assert "risk_score" in result | |
| # The result should have epistemic_signals (zeros) even without model | |
| assert result["epistemic_signals"] is not None | |