feat(guardrails): añade Protocol GuardrailEngine
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -11,4 +11,5 @@ presidio-analyzer>=2.2,<3.0
|
||||
presidio-anonymizer>=2.2,<3.0
|
||||
openai>=1.50,<2.0
|
||||
PyYAML>=6.0,<7.0
|
||||
jsonschema>=4.0,<5.0
|
||||
nemoguardrails>=0.10,<0.12
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Interfaz Protocol del motor de guardrails."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Protocol
|
||||
from uuid import UUID
|
||||
|
||||
from agentforge_core.domain.guardrail import GuardrailViolation
|
||||
from agentforge_core.domain.policy import PolicyDefinition
|
||||
|
||||
|
||||
class GuardrailEngine(Protocol):
|
||||
"""Motor de validación. Las violaciones se devuelven; el grafo decide bloquear."""
|
||||
|
||||
name: str
|
||||
|
||||
async def validate_input(
|
||||
self,
|
||||
payload: str,
|
||||
policy: PolicyDefinition,
|
||||
trace_id: UUID,
|
||||
) -> list[GuardrailViolation]: ...
|
||||
|
||||
async def validate_output(
|
||||
self,
|
||||
payload: dict[str, Any],
|
||||
policy: PolicyDefinition,
|
||||
trace_id: UUID,
|
||||
) -> list[GuardrailViolation]: ...
|
||||
Reference in New Issue
Block a user