activity-core/tests/test_audit_projection.py
tegwick 26934e25b9
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Container Image / build-and-push (push) Successful in 21s
Enforce bounded operation guardrails
Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a028de-e2c8-7732-8521-46a7fc5db82f
2026-08-23 12:31:13 +02:00

40 lines
1.3 KiB
Python

from __future__ import annotations
from activity_core.audit_projection import bounded_audit_projection
def test_audit_projection_drops_raw_and_credential_shaped_fields() -> None:
raw = {
"definition_id": "daily-triage",
"prompt_hash": "a" * 64,
"context": {
"summary": "bounded",
"rendered_prompt": "do not persist",
"messages": [{"content": "do not persist"}],
"provider_response": {"body": "do not persist"},
"tool_output": "do not persist",
"credential": "do not persist",
"api_key": "do not persist",
"nested": {"password": "do not persist", "safe": True},
},
}
projected = bounded_audit_projection(raw)
assert projected == {
"definition_id": "daily-triage",
"prompt_hash": "a" * 64,
"context": {"summary": "bounded", "nested": {"safe": True}},
}
assert "do not persist" not in str(projected)
def test_audit_projection_bounds_depth_items_and_strings() -> None:
projected = bounded_audit_projection(
{"text": "x" * 20, "items": list(range(5)), "nested": {"value": 1}},
max_depth=1,
max_items=2,
max_string=5,
)
assert projected == {"text": "xxxxx", "items": ["<depth-limit>", "<depth-limit>"]}