cortexhub 0.5.0__tar.gz → 0.5.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. {cortexhub-0.5.0 → cortexhub-0.5.1}/PKG-INFO +1 -1
  2. {cortexhub-0.5.0 → cortexhub-0.5.1}/pyproject.toml +1 -1
  3. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/backend/client.py +22 -2
  4. cortexhub-0.5.1/src/cortexhub/policy/effects.py +249 -0
  5. cortexhub-0.5.0/src/cortexhub/policy/effects.py +0 -152
  6. {cortexhub-0.5.0 → cortexhub-0.5.1}/.gitignore +0 -0
  7. {cortexhub-0.5.0 → cortexhub-0.5.1}/LICENSE +0 -0
  8. {cortexhub-0.5.0 → cortexhub-0.5.1}/README.md +0 -0
  9. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/__init__.py +0 -0
  10. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/audit/__init__.py +0 -0
  11. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/audit/events.py +0 -0
  12. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/backend/__init__.py +0 -0
  13. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/client.py +0 -0
  14. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/config.py +0 -0
  15. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/constants.py +0 -0
  16. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/context/__init__.py +0 -0
  17. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/context/enricher.py +0 -0
  18. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/errors.py +0 -0
  19. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/__init__.py +0 -0
  20. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/injection.py +0 -0
  21. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/__init__.py +0 -0
  22. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSE +0 -0
  23. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSES_SOURCES +0 -0
  24. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/README.md +0 -0
  25. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/accuracy.json +0 -0
  26. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/attribute_ruler/patterns +0 -0
  27. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/config.cfg +0 -0
  28. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/lemmatizer/lookups/lookups.bin +0 -0
  29. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/meta.json +0 -0
  30. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/cfg +0 -0
  31. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/model +0 -0
  32. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/moves +0 -0
  33. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/cfg +0 -0
  34. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/model +0 -0
  35. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/moves +0 -0
  36. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/cfg +0 -0
  37. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/model +0 -0
  38. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/cfg +0 -0
  39. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/model +0 -0
  40. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/cfg +0 -0
  41. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/model +0 -0
  42. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tokenizer +0 -0
  43. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/key2row +0 -0
  44. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/lookups.bin +0 -0
  45. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/strings.json +0 -0
  46. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors +0 -0
  47. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors.cfg +0 -0
  48. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/models/en_core_web_sm/meta.json +0 -0
  49. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/pii.py +0 -0
  50. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/guardrails/secrets.py +0 -0
  51. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/interceptors/__init__.py +0 -0
  52. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/interceptors/mcp.py +0 -0
  53. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/logging.py +0 -0
  54. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/policy/__init__.py +0 -0
  55. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/policy/evaluator.py +0 -0
  56. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/policy/loader.py +0 -0
  57. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/policy/models.py +0 -0
  58. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/policy/sync.py +0 -0
  59. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/signing.py +0 -0
  60. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/telemetry/__init__.py +0 -0
  61. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/telemetry/otel.py +0 -0
  62. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/tool.py +0 -0
  63. {cortexhub-0.5.0 → cortexhub-0.5.1}/src/cortexhub/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cortexhub
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: CortexHub Python SDK — Runtime governance for AI systems. One decorator, any tool, any framework.
5
5
  Project-URL: Homepage, https://cortexhub.ai
6
6
  Project-URL: Documentation, https://docs.cortexhub.ai
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "cortexhub"
3
- version = "0.5.0"
3
+ version = "0.5.1"
4
4
  description = "CortexHub Python SDK — Runtime governance for AI systems. One decorator, any tool, any framework."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10,<3.13"
@@ -11,6 +11,24 @@ import structlog
11
11
  logger = structlog.get_logger(__name__)
12
12
 
13
13
 
14
+ def _extract_error_message(body: Any) -> str | None:
15
+ """Return a human‑readable error message from either the standard
16
+ CortexHub envelope ``{"error": {"code","message","details"}}`` or a
17
+ legacy FastAPI ``{"detail": "..."}`` body. Returns ``None`` when neither
18
+ shape is present."""
19
+ if not isinstance(body, dict):
20
+ return None
21
+ err = body.get("error")
22
+ if isinstance(err, dict):
23
+ msg = err.get("message")
24
+ if isinstance(msg, str) and msg:
25
+ return msg
26
+ detail = body.get("detail")
27
+ if isinstance(detail, str) and detail:
28
+ return detail
29
+ return None
30
+
31
+
14
32
  @dataclass
15
33
  class CustomPattern:
16
34
  """Custom regex pattern for detection."""
@@ -381,9 +399,11 @@ class BackendClient:
381
399
  else:
382
400
  try:
383
401
  body = response.json()
384
- error_detail = body.get("detail", "Invalid agent key") if isinstance(body, dict) else str(body)
385
402
  except Exception:
386
- error_detail = (response.text or "")[:500] or f"HTTP {response.status_code}"
403
+ body = None
404
+ error_detail = _extract_error_message(body) or (
405
+ (response.text or "")[:500] or f"HTTP {response.status_code}"
406
+ )
387
407
  logger.warning("Agent key validation failed", error=error_detail)
388
408
  return False, None
389
409
 
@@ -0,0 +1,249 @@
1
+ """Decision effects from policy evaluation.
2
+
3
+ Vocabulary follows the five AARM decisions:
4
+
5
+ * ``permit`` — allow the action as‑is.
6
+ * ``deny`` — block the action.
7
+ * ``modify`` — allow the action with rewritten arguments (PII redaction,
8
+ value clamps, field removal). ``redact`` is a narrower
9
+ synonym kept for dashboards that filter by it.
10
+ * ``step_up`` — require human approval before the action runs.
11
+ ``escalate`` is the historical SDK name and remains a
12
+ synonym so existing integrations keep working.
13
+ * ``defer`` — suspend the decision pending additional context (rarely
14
+ emitted by the SDK today; included so telemetry
15
+ vocabulary matches AARM end‑to‑end).
16
+
17
+ The evaluator is deterministic: the same ``AuthorizationRequest`` MUST
18
+ always produce the same ``Decision``.
19
+ """
20
+
21
+ from enum import Enum
22
+
23
+ from pydantic import BaseModel
24
+
25
+
26
+ class Effect(str, Enum):
27
+ """Policy decision effect (AARM R4)."""
28
+
29
+ PERMIT = "permit"
30
+ DENY = "deny"
31
+ MODIFY = "modify"
32
+ STEP_UP = "step_up"
33
+ DEFER = "defer"
34
+
35
+ # Historical SDK values — kept so existing customer code comparing
36
+ # ``decision.effect == Effect.ESCALATE`` keeps working. New code should
37
+ # prefer STEP_UP / MODIFY.
38
+ ESCALATE = "escalate"
39
+ REDACT = "redact"
40
+
41
+
42
+ class Decision(BaseModel):
43
+ """Result of policy evaluation.
44
+
45
+ Attributes
46
+ ----------
47
+ effect
48
+ One of the AARM decisions.
49
+ reasoning
50
+ Human‑readable explanation shown in span events and dashboards.
51
+ policy_id / policy_name
52
+ Which policy produced the decision.
53
+ policy_effect
54
+ Policy effect metadata (if available).
55
+ policy_decisions
56
+ All matching policy decisions (if available).
57
+ policy_timeout_behavior
58
+ For step‑up decisions: ``"deny"`` (default) or ``"allow"`` — what
59
+ happens when ``wait_for_approval`` times out.
60
+ modified_args
61
+ For ``modify`` decisions: the rewritten argument dict the tool
62
+ should be invoked with. ``None`` for other decisions.
63
+ """
64
+
65
+ effect: Effect
66
+ reasoning: str
67
+ policy_id: str | None = None
68
+ policy_name: str | None = None
69
+ policy_effect: str | None = None
70
+ policy_decisions: list[dict[str, str | None]] | None = None
71
+ policy_timeout_behavior: str | None = None
72
+ modified_args: dict[str, object] | None = None
73
+
74
+ # ── Predicates ───────────────────────────────────────────────────────
75
+ def is_allowed(self) -> bool:
76
+ """True for ``permit`` decisions."""
77
+ return self.effect == Effect.PERMIT
78
+
79
+ def is_denied(self) -> bool:
80
+ """True for ``deny`` decisions."""
81
+ return self.effect == Effect.DENY
82
+
83
+ def is_modified(self) -> bool:
84
+ """True when policy rewrote arguments (``modify`` or the legacy ``redact``)."""
85
+ return self.effect in (Effect.MODIFY, Effect.REDACT)
86
+
87
+ def is_redacted(self) -> bool:
88
+ """True specifically for the legacy ``redact`` effect."""
89
+ return self.effect == Effect.REDACT
90
+
91
+ def requires_approval(self) -> bool:
92
+ """True when human approval is required (``step_up`` / legacy ``escalate``)."""
93
+ return self.effect in (Effect.STEP_UP, Effect.ESCALATE)
94
+
95
+ def is_deferred(self) -> bool:
96
+ """True when the decision is suspended pending more context."""
97
+ return self.effect == Effect.DEFER
98
+
99
+ # ── Factories ────────────────────────────────────────────────────────
100
+ @classmethod
101
+ def permit(
102
+ cls,
103
+ reasoning: str = "Permitted by policy",
104
+ policy_id: str | None = None,
105
+ policy_name: str | None = None,
106
+ policy_effect: str | None = None,
107
+ policy_decisions: list[dict[str, str | None]] | None = None,
108
+ ) -> "Decision":
109
+ return cls(
110
+ effect=Effect.PERMIT,
111
+ reasoning=reasoning,
112
+ policy_id=policy_id,
113
+ policy_name=policy_name,
114
+ policy_effect=policy_effect,
115
+ policy_decisions=policy_decisions,
116
+ )
117
+
118
+ @classmethod
119
+ def allow(
120
+ cls,
121
+ reasoning: str = "Permitted by policy",
122
+ policy_id: str | None = None,
123
+ policy_name: str | None = None,
124
+ policy_effect: str | None = None,
125
+ policy_decisions: list[dict[str, str | None]] | None = None,
126
+ ) -> "Decision":
127
+ """Alias for :meth:`permit` kept for older SDK users."""
128
+ return cls.permit(
129
+ reasoning=reasoning,
130
+ policy_id=policy_id,
131
+ policy_name=policy_name,
132
+ policy_effect=policy_effect,
133
+ policy_decisions=policy_decisions,
134
+ )
135
+
136
+ @classmethod
137
+ def deny(
138
+ cls,
139
+ reasoning: str,
140
+ policy_id: str | None = None,
141
+ policy_name: str | None = None,
142
+ policy_effect: str | None = None,
143
+ policy_decisions: list[dict[str, str | None]] | None = None,
144
+ ) -> "Decision":
145
+ return cls(
146
+ effect=Effect.DENY,
147
+ reasoning=reasoning,
148
+ policy_id=policy_id,
149
+ policy_name=policy_name,
150
+ policy_effect=policy_effect,
151
+ policy_decisions=policy_decisions,
152
+ )
153
+
154
+ @classmethod
155
+ def modify(
156
+ cls,
157
+ reasoning: str,
158
+ modified_args: dict[str, object],
159
+ policy_id: str | None = None,
160
+ policy_name: str | None = None,
161
+ ) -> "Decision":
162
+ """Allow the action with rewritten arguments (AARM MODIFY)."""
163
+ return cls(
164
+ effect=Effect.MODIFY,
165
+ reasoning=reasoning,
166
+ policy_id=policy_id,
167
+ policy_name=policy_name,
168
+ modified_args=modified_args,
169
+ )
170
+
171
+ @classmethod
172
+ def redact(
173
+ cls,
174
+ reasoning: str,
175
+ policy_id: str | None = None,
176
+ policy_name: str | None = None,
177
+ policy_effect: str | None = None,
178
+ policy_decisions: list[dict[str, str | None]] | None = None,
179
+ ) -> "Decision":
180
+ """Narrower alias of :meth:`modify` emitted when PII / secrets were
181
+ redacted before the action ran. Preferred for backwards compatibility
182
+ with existing dashboards that filter by ``redact``.
183
+ """
184
+ return cls(
185
+ effect=Effect.REDACT,
186
+ reasoning=reasoning,
187
+ policy_id=policy_id,
188
+ policy_name=policy_name,
189
+ policy_effect=policy_effect,
190
+ policy_decisions=policy_decisions,
191
+ )
192
+
193
+ @classmethod
194
+ def step_up(
195
+ cls,
196
+ reasoning: str,
197
+ policy_id: str | None = None,
198
+ policy_name: str | None = None,
199
+ policy_effect: str | None = None,
200
+ policy_decisions: list[dict[str, str | None]] | None = None,
201
+ policy_timeout_behavior: str | None = None,
202
+ ) -> "Decision":
203
+ """Require human approval before the action runs (AARM STEP_UP)."""
204
+ return cls(
205
+ effect=Effect.STEP_UP,
206
+ reasoning=reasoning,
207
+ policy_id=policy_id,
208
+ policy_name=policy_name,
209
+ policy_effect=policy_effect,
210
+ policy_decisions=policy_decisions,
211
+ policy_timeout_behavior=policy_timeout_behavior,
212
+ )
213
+
214
+ @classmethod
215
+ def escalate(
216
+ cls,
217
+ reasoning: str,
218
+ policy_id: str | None = None,
219
+ policy_name: str | None = None,
220
+ policy_effect: str | None = None,
221
+ policy_decisions: list[dict[str, str | None]] | None = None,
222
+ policy_timeout_behavior: str | None = None,
223
+ ) -> "Decision":
224
+ """Legacy SDK factory. Identical to :meth:`step_up` but emits the
225
+ ``escalate`` effect so older dashboards keep filtering correctly."""
226
+ return cls(
227
+ effect=Effect.ESCALATE,
228
+ reasoning=reasoning,
229
+ policy_id=policy_id,
230
+ policy_name=policy_name,
231
+ policy_effect=policy_effect,
232
+ policy_decisions=policy_decisions,
233
+ policy_timeout_behavior=policy_timeout_behavior,
234
+ )
235
+
236
+ @classmethod
237
+ def defer(
238
+ cls,
239
+ reasoning: str,
240
+ policy_id: str | None = None,
241
+ policy_name: str | None = None,
242
+ ) -> "Decision":
243
+ """Suspend the decision pending more context (AARM DEFER)."""
244
+ return cls(
245
+ effect=Effect.DEFER,
246
+ reasoning=reasoning,
247
+ policy_id=policy_id,
248
+ policy_name=policy_name,
249
+ )
@@ -1,152 +0,0 @@
1
- """Decision effects from policy evaluation.
2
-
3
- Critical: Determinism guarantee - Same AuthorizationRequest MUST always produce
4
- same Decision. This is essential for testing and auditability.
5
- """
6
-
7
- from enum import Enum
8
-
9
- from pydantic import BaseModel
10
-
11
-
12
- class Effect(str, Enum):
13
- """Policy decision effect (v2: permit / deny / escalate in telemetry)."""
14
-
15
- PERMIT = "permit"
16
- DENY = "deny"
17
- ESCALATE = "escalate"
18
- REDACT = "redact" # PII/secrets were redacted before LLM call
19
-
20
-
21
- class Decision(BaseModel):
22
- """Result of policy evaluation.
23
-
24
- Attributes:
25
- effect: The decision (PERMIT/DENY/ESCALATE)
26
- reasoning: Human-readable explanation
27
- policy_id: Which policy triggered this decision (if any)
28
- policy_name: Friendly policy name (if available)
29
- policy_effect: Policy effect metadata (if available)
30
- policy_decisions: All matching policy decisions (if available)
31
- """
32
-
33
- effect: Effect
34
- reasoning: str
35
- policy_id: str | None = None
36
- policy_name: str | None = None
37
- policy_effect: str | None = None
38
- policy_decisions: list[dict[str, str | None]] | None = None
39
- # When approval expires or wait times out: "deny" (default) or "allow"
40
- policy_timeout_behavior: str | None = None
41
-
42
- def is_allowed(self) -> bool:
43
- """Check if the decision allows execution (permit)."""
44
- return self.effect == Effect.PERMIT
45
-
46
- def is_denied(self) -> bool:
47
- """Check if the decision denies execution."""
48
- return self.effect == Effect.DENY
49
-
50
- def requires_approval(self) -> bool:
51
- """Check if the decision requires approval (escalation)."""
52
- return self.effect == Effect.ESCALATE
53
-
54
- @classmethod
55
- def permit(
56
- cls,
57
- reasoning: str = "Permitted by policy",
58
- policy_id: str | None = None,
59
- policy_name: str | None = None,
60
- policy_effect: str | None = None,
61
- policy_decisions: list[dict[str, str | None]] | None = None,
62
- ):
63
- """Create a PERMIT decision."""
64
- return cls(
65
- effect=Effect.PERMIT,
66
- reasoning=reasoning,
67
- policy_id=policy_id,
68
- policy_name=policy_name,
69
- policy_effect=policy_effect,
70
- policy_decisions=policy_decisions,
71
- )
72
-
73
- @classmethod
74
- def allow(
75
- cls,
76
- reasoning: str = "Permitted by policy",
77
- policy_id: str | None = None,
78
- policy_name: str | None = None,
79
- policy_effect: str | None = None,
80
- policy_decisions: list[dict[str, str | None]] | None = None,
81
- ):
82
- """Deprecated alias for :meth:`permit` (same effect: ``permit``)."""
83
- return cls.permit(
84
- reasoning=reasoning,
85
- policy_id=policy_id,
86
- policy_name=policy_name,
87
- policy_effect=policy_effect,
88
- policy_decisions=policy_decisions,
89
- )
90
-
91
- @classmethod
92
- def deny(
93
- cls,
94
- reasoning: str,
95
- policy_id: str | None = None,
96
- policy_name: str | None = None,
97
- policy_effect: str | None = None,
98
- policy_decisions: list[dict[str, str | None]] | None = None,
99
- ):
100
- """Create a DENY decision."""
101
- return cls(
102
- effect=Effect.DENY,
103
- reasoning=reasoning,
104
- policy_id=policy_id,
105
- policy_name=policy_name,
106
- policy_effect=policy_effect,
107
- policy_decisions=policy_decisions,
108
- )
109
-
110
- @classmethod
111
- def escalate(
112
- cls,
113
- reasoning: str,
114
- policy_id: str | None = None,
115
- policy_name: str | None = None,
116
- policy_effect: str | None = None,
117
- policy_decisions: list[dict[str, str | None]] | None = None,
118
- policy_timeout_behavior: str | None = None,
119
- ):
120
- """Create an ESCALATE decision."""
121
- return cls(
122
- effect=Effect.ESCALATE,
123
- reasoning=reasoning,
124
- policy_id=policy_id,
125
- policy_name=policy_name,
126
- policy_effect=policy_effect,
127
- policy_decisions=policy_decisions,
128
- policy_timeout_behavior=policy_timeout_behavior,
129
- )
130
-
131
- @classmethod
132
- def redact(
133
- cls,
134
- reasoning: str,
135
- policy_id: str | None = None,
136
- policy_name: str | None = None,
137
- policy_effect: str | None = None,
138
- policy_decisions: list[dict[str, str | None]] | None = None,
139
- ):
140
- """Create a REDACT decision (PII/secrets were redacted before execution)."""
141
- return cls(
142
- effect=Effect.REDACT,
143
- reasoning=reasoning,
144
- policy_id=policy_id,
145
- policy_name=policy_name,
146
- policy_effect=policy_effect,
147
- policy_decisions=policy_decisions,
148
- )
149
-
150
- def is_redacted(self) -> bool:
151
- """Check if the decision resulted in redaction."""
152
- return self.effect == Effect.REDACT
File without changes
File without changes
File without changes