feat(cli): add response guardrails and grounded followup re-anchoring
This commit is contained in:
24
tests/test_ai_guardrails.py
Normal file
24
tests/test_ai_guardrails.py
Normal file
@@ -0,0 +1,24 @@
|
||||
"""Tests for AI response guardrails."""
|
||||
|
||||
from tai.ai_guardrails import validate_ai_response
|
||||
|
||||
|
||||
def test_validate_ai_response_flags_missing_evidence_and_quotes() -> None:
|
||||
warnings = validate_ai_response("Root cause only, no structure.")
|
||||
assert any("Evidence section" in item for item in warnings)
|
||||
assert any("quoted evidence" in item for item in warnings)
|
||||
|
||||
|
||||
def test_validate_ai_response_flags_risky_actions() -> None:
|
||||
text = "Evidence: `PasswordAuthentication no`\nRun systemctl restart sshd now."
|
||||
warnings = validate_ai_response(text)
|
||||
assert any("modifying actions" in item for item in warnings)
|
||||
|
||||
|
||||
def test_validate_ai_response_allows_grounded_read_only_answer() -> None:
|
||||
text = (
|
||||
"Evidence: `PasswordAuthentication no`\n"
|
||||
"Recommended Actions: run `journalctl -u sshd -n 200 --no-pager`"
|
||||
)
|
||||
warnings = validate_ai_response(text)
|
||||
assert not warnings
|
||||
Reference in New Issue
Block a user