Skip to content

Commit b151e2b

Browse files
authored
feat: RFC-005 Step 9 — PIP request builder types (#46)
* feat: add RFC-005 PIP request builder types Add capiscio_sdk/pip.py with PIP request/response dataclasses for SDK consumers building custom PEP integrations: - PIPRequest, PIPResponse, Obligation (request/response types) - SubjectAttributes, ActionAttributes, ResourceAttributes, ContextAttributes, EnvironmentAttributes (attribute groups) - EnforcementMode enum with stricter_than() and from_env() - Constants: PIP_VERSION, DECISION_ALLOW, DECISION_DENY, DECISION_OBSERVE - Auto-populates txn_id (UUID v7/v4) and environment.time (ISO 8601) - Envelope fields serialize as JSON null (not absent) in badge-only mode RFC-005 Step 9 implementation. 44 unit tests, full serialization roundtrip coverage. * fix: normalize EnforcementMode enum to string in ContextAttributes Accept Union[str, EnforcementMode] for enforcement_mode and normalize to string value in __post_init__. This prevents json.dumps() failures when callers pass EnforcementMode.from_env() directly. Addresses PR review feedback.
1 parent b083a37 commit b151e2b

3 files changed

Lines changed: 852 additions & 0 deletions

File tree

capiscio_sdk/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@
6666
# Event emission
6767
from .events import EventEmitter
6868

69+
# RFC-005: PIP request/response types
70+
from .pip import (
71+
PIPRequest,
72+
PIPResponse,
73+
SubjectAttributes,
74+
ActionAttributes,
75+
ResourceAttributes,
76+
ContextAttributes,
77+
EnvironmentAttributes,
78+
Obligation as PIPObligation,
79+
EnforcementMode,
80+
PIP_VERSION,
81+
DECISION_ALLOW,
82+
DECISION_DENY,
83+
DECISION_OBSERVE,
84+
)
85+
6986
__all__ = [
7087
"__version__",
7188
# Security middleware
@@ -119,5 +136,19 @@
119136
"AgentIdentity",
120137
# Event emission
121138
"EventEmitter",
139+
# RFC-005: PIP types
140+
"PIPRequest",
141+
"PIPResponse",
142+
"SubjectAttributes",
143+
"ActionAttributes",
144+
"ResourceAttributes",
145+
"ContextAttributes",
146+
"EnvironmentAttributes",
147+
"PIPObligation",
148+
"EnforcementMode",
149+
"PIP_VERSION",
150+
"DECISION_ALLOW",
151+
"DECISION_DENY",
152+
"DECISION_OBSERVE",
122153
]
123154

0 commit comments

Comments
 (0)