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": ["", ""]}