cortexhub 0.5.1__tar.gz → 0.5.2__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.1 → cortexhub-0.5.2}/PKG-INFO +1 -1
  2. {cortexhub-0.5.1 → cortexhub-0.5.2}/pyproject.toml +1 -1
  3. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/client.py +6 -6
  4. cortexhub-0.5.2/src/cortexhub/policy/effects.py +138 -0
  5. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/policy/evaluator.py +3 -3
  6. cortexhub-0.5.1/src/cortexhub/policy/effects.py +0 -249
  7. {cortexhub-0.5.1 → cortexhub-0.5.2}/.gitignore +0 -0
  8. {cortexhub-0.5.1 → cortexhub-0.5.2}/LICENSE +0 -0
  9. {cortexhub-0.5.1 → cortexhub-0.5.2}/README.md +0 -0
  10. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/__init__.py +0 -0
  11. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/audit/__init__.py +0 -0
  12. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/audit/events.py +0 -0
  13. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/backend/__init__.py +0 -0
  14. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/backend/client.py +0 -0
  15. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/config.py +0 -0
  16. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/constants.py +0 -0
  17. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/context/__init__.py +0 -0
  18. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/context/enricher.py +0 -0
  19. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/errors.py +0 -0
  20. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/__init__.py +0 -0
  21. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/injection.py +0 -0
  22. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/__init__.py +0 -0
  23. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSE +0 -0
  24. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/LICENSES_SOURCES +0 -0
  25. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/README.md +0 -0
  26. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/accuracy.json +0 -0
  27. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/attribute_ruler/patterns +0 -0
  28. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/config.cfg +0 -0
  29. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/lemmatizer/lookups/lookups.bin +0 -0
  30. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/meta.json +0 -0
  31. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/cfg +0 -0
  32. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/model +0 -0
  33. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/ner/moves +0 -0
  34. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/cfg +0 -0
  35. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/model +0 -0
  36. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/parser/moves +0 -0
  37. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/cfg +0 -0
  38. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/senter/model +0 -0
  39. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/cfg +0 -0
  40. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tagger/model +0 -0
  41. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/cfg +0 -0
  42. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tok2vec/model +0 -0
  43. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/tokenizer +0 -0
  44. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/key2row +0 -0
  45. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/lookups.bin +0 -0
  46. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/strings.json +0 -0
  47. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors +0 -0
  48. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/en_core_web_sm-3.8.0/vocab/vectors.cfg +0 -0
  49. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/models/en_core_web_sm/meta.json +0 -0
  50. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/pii.py +0 -0
  51. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/guardrails/secrets.py +0 -0
  52. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/interceptors/__init__.py +0 -0
  53. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/interceptors/mcp.py +0 -0
  54. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/logging.py +0 -0
  55. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/policy/__init__.py +0 -0
  56. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/policy/loader.py +0 -0
  57. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/policy/models.py +0 -0
  58. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/policy/sync.py +0 -0
  59. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/signing.py +0 -0
  60. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/telemetry/__init__.py +0 -0
  61. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/telemetry/otel.py +0 -0
  62. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/tool.py +0 -0
  63. {cortexhub-0.5.1 → cortexhub-0.5.2}/src/cortexhub/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cortexhub
3
- Version: 0.5.1
3
+ Version: 0.5.2
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.1"
3
+ version = "0.5.2"
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"
@@ -1526,7 +1526,7 @@ class CortexHub:
1526
1526
  reasoning=decision.reasoning,
1527
1527
  )
1528
1528
 
1529
- if decision and decision.effect == Effect.ESCALATE:
1529
+ if decision and decision.effect == Effect.STEP_UP:
1530
1530
  context_hash = self._compute_context_hash(tool_name, policy_args)
1531
1531
 
1532
1532
  with self._approval_lock:
@@ -1540,7 +1540,7 @@ class CortexHub:
1540
1540
  context_hash=context_hash,
1541
1541
  )
1542
1542
  span.set_attribute("cortexhub.approval_id", approval_id)
1543
- decision = Decision.allow(
1543
+ decision = Decision.permit(
1544
1544
  reasoning=f"Approved (previously granted via {approval_id})",
1545
1545
  policy_id=decision.policy_id,
1546
1546
  policy_name=decision.policy_name,
@@ -1579,7 +1579,7 @@ class CortexHub:
1579
1579
  approval_id=pending_id,
1580
1580
  )
1581
1581
  span.set_attribute("cortexhub.approval_id", pending_id)
1582
- decision = Decision.allow(
1582
+ decision = Decision.permit(
1583
1583
  reasoning=f"Approved (auto-granted via {pending_id})",
1584
1584
  policy_id=decision.policy_id,
1585
1585
  policy_name=decision.policy_name,
@@ -1911,7 +1911,7 @@ class CortexHub:
1911
1911
  reasoning=decision.reasoning,
1912
1912
  )
1913
1913
 
1914
- if decision and decision.effect == Effect.ESCALATE:
1914
+ if decision and decision.effect == Effect.STEP_UP:
1915
1915
  context_hash = self._compute_context_hash(tool_name, policy_args)
1916
1916
 
1917
1917
  with self._approval_lock:
@@ -1924,7 +1924,7 @@ class CortexHub:
1924
1924
  context_hash=context_hash,
1925
1925
  )
1926
1926
  span.set_attribute("cortexhub.approval_id", approval_id)
1927
- decision = Decision.allow(
1927
+ decision = Decision.permit(
1928
1928
  reasoning=f"Approved (previously granted via {approval_id})",
1929
1929
  policy_id=decision.policy_id,
1930
1930
  policy_name=decision.policy_name,
@@ -1958,7 +1958,7 @@ class CortexHub:
1958
1958
  approval_id=pending_id,
1959
1959
  )
1960
1960
  span.set_attribute("cortexhub.approval_id", pending_id)
1961
- decision = Decision.allow(
1961
+ decision = Decision.permit(
1962
1962
  reasoning=f"Approved (auto-granted via {pending_id})",
1963
1963
  policy_id=decision.policy_id,
1964
1964
  policy_name=decision.policy_name,
@@ -0,0 +1,138 @@
1
+ """Policy decision effects — AARM vocabulary (R4).
2
+
3
+ Every governed tool call resolves to exactly one of these five decisions.
4
+ The evaluator is deterministic: the same ``AuthorizationRequest`` MUST
5
+ always produce the same ``Decision``.
6
+ """
7
+
8
+ from enum import Enum
9
+
10
+ from pydantic import BaseModel
11
+
12
+
13
+ class Effect(str, Enum):
14
+ """The five AARM authorization decisions."""
15
+
16
+ PERMIT = "permit"
17
+ DENY = "deny"
18
+ MODIFY = "modify"
19
+ STEP_UP = "step_up"
20
+ DEFER = "defer"
21
+
22
+
23
+ class Decision(BaseModel):
24
+ """Result of policy evaluation."""
25
+
26
+ effect: Effect
27
+ reasoning: str
28
+ policy_id: str | None = None
29
+ policy_name: str | None = None
30
+ policy_effect: str | None = None
31
+ policy_decisions: list[dict[str, str | None]] | None = None
32
+ policy_timeout_behavior: str | None = None
33
+ modified_args: dict[str, object] | None = None
34
+
35
+ def is_permitted(self) -> bool:
36
+ return self.effect == Effect.PERMIT
37
+
38
+ def is_denied(self) -> bool:
39
+ return self.effect == Effect.DENY
40
+
41
+ def is_modified(self) -> bool:
42
+ return self.effect == Effect.MODIFY
43
+
44
+ def requires_approval(self) -> bool:
45
+ return self.effect == Effect.STEP_UP
46
+
47
+ def is_deferred(self) -> bool:
48
+ return self.effect == Effect.DEFER
49
+
50
+ @classmethod
51
+ def permit(
52
+ cls,
53
+ reasoning: str = "Permitted by policy",
54
+ policy_id: str | None = None,
55
+ policy_name: str | None = None,
56
+ policy_effect: str | None = None,
57
+ policy_decisions: list[dict[str, str | None]] | None = None,
58
+ ) -> "Decision":
59
+ return cls(
60
+ effect=Effect.PERMIT,
61
+ reasoning=reasoning,
62
+ policy_id=policy_id,
63
+ policy_name=policy_name,
64
+ policy_effect=policy_effect,
65
+ policy_decisions=policy_decisions,
66
+ )
67
+
68
+ @classmethod
69
+ def deny(
70
+ cls,
71
+ reasoning: str,
72
+ policy_id: str | None = None,
73
+ policy_name: str | None = None,
74
+ policy_effect: str | None = None,
75
+ policy_decisions: list[dict[str, str | None]] | None = None,
76
+ ) -> "Decision":
77
+ return cls(
78
+ effect=Effect.DENY,
79
+ reasoning=reasoning,
80
+ policy_id=policy_id,
81
+ policy_name=policy_name,
82
+ policy_effect=policy_effect,
83
+ policy_decisions=policy_decisions,
84
+ )
85
+
86
+ @classmethod
87
+ def modify(
88
+ cls,
89
+ reasoning: str,
90
+ modified_args: dict[str, object],
91
+ policy_id: str | None = None,
92
+ policy_name: str | None = None,
93
+ ) -> "Decision":
94
+ """Execute the tool with ``modified_args`` instead of the original
95
+ arguments (e.g. PII redacted, values clamped)."""
96
+ return cls(
97
+ effect=Effect.MODIFY,
98
+ reasoning=reasoning,
99
+ policy_id=policy_id,
100
+ policy_name=policy_name,
101
+ modified_args=modified_args,
102
+ )
103
+
104
+ @classmethod
105
+ def step_up(
106
+ cls,
107
+ reasoning: str,
108
+ policy_id: str | None = None,
109
+ policy_name: str | None = None,
110
+ policy_effect: str | None = None,
111
+ policy_decisions: list[dict[str, str | None]] | None = None,
112
+ policy_timeout_behavior: str | None = None,
113
+ ) -> "Decision":
114
+ """Require a human approval before the tool runs."""
115
+ return cls(
116
+ effect=Effect.STEP_UP,
117
+ reasoning=reasoning,
118
+ policy_id=policy_id,
119
+ policy_name=policy_name,
120
+ policy_effect=policy_effect,
121
+ policy_decisions=policy_decisions,
122
+ policy_timeout_behavior=policy_timeout_behavior,
123
+ )
124
+
125
+ @classmethod
126
+ def defer(
127
+ cls,
128
+ reasoning: str,
129
+ policy_id: str | None = None,
130
+ policy_name: str | None = None,
131
+ ) -> "Decision":
132
+ """Suspend the decision pending more context."""
133
+ return cls(
134
+ effect=Effect.DEFER,
135
+ reasoning=reasoning,
136
+ policy_id=policy_id,
137
+ policy_name=policy_name,
138
+ )
@@ -128,7 +128,7 @@ class PolicyEvaluator:
128
128
  policy_decisions=[],
129
129
  )
130
130
  if self.default_behavior == "escalate":
131
- return Decision.escalate(
131
+ return Decision.step_up(
132
132
  f"Tool '{tool_name}' requires approval (unknown tool)",
133
133
  policy_id="default",
134
134
  policy_decisions=[],
@@ -286,7 +286,7 @@ class PolicyEvaluator:
286
286
  if result.decision == cedar_module.Decision.Deny:
287
287
  # Engine Deny: one or more forbid policies matched. Never allow, even when reasons are empty.
288
288
  if not result.diagnostics.reasons:
289
- return Decision.escalate(
289
+ return Decision.step_up(
290
290
  "Tool requires approval (policy condition matched)",
291
291
  policy_id="policy",
292
292
  policy_decisions=policy_decisions,
@@ -318,7 +318,7 @@ class PolicyEvaluator:
318
318
  timeout_behavior = "deny"
319
319
  if first_reason and policy_map:
320
320
  timeout_behavior = (policy_map.get(first_reason, {}).get("approval_timeout_behavior") or "deny").lower()
321
- return Decision.escalate(
321
+ return Decision.step_up(
322
322
  reasoning="Approval required by policy",
323
323
  policy_id=policy_id,
324
324
  policy_name=policy_name,
@@ -1,249 +0,0 @@
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
- )
File without changes
File without changes
File without changes