Enforce bounded operation guardrails
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a028de-e2c8-7732-8521-46a7fc5db82f
This commit is contained in:
parent
c384f60530
commit
26934e25b9
51 changed files with 1843 additions and 472 deletions
40
tests/test_audit_projection.py
Normal file
40
tests/test_audit_projection.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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>"]}
|
||||
Loading…
Add table
Add a link
Reference in a new issue