iris-security-sdk 0.1.9__tar.gz → 0.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris-security-sdk
3
- Version: 0.1.9
3
+ Version: 0.2.0
4
4
  Summary: IRIS — AI Agent Governance SDK. Govern AI agents locally.
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/gimartinb/iris-sdk
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
- Requires-Dist: iris-security-core>=0.1.7
19
+ Requires-Dist: iris-security-core>=0.1.8
20
20
  Requires-Dist: pyyaml>=6.0
21
21
  Requires-Dist: pydantic>=2.0
22
22
  Requires-Dist: click>=8.1
@@ -36,6 +36,9 @@ from iris_core.models.passport import (
36
36
  ToolPermission,
37
37
  UserContext,
38
38
  )
39
+ from iris_core.hitl.models import HITLConfig, HITLConditionRule, HITLStatus
40
+ from iris_core.hitl.error import IrisHITLRequiredError
41
+ from iris.hitl import HITLPoller
39
42
  from iris_core.models.policy import PolicyResult, Violation, Severity
40
43
  from iris_core.engine.cedar import CedarEngine, EvaluationContext
41
44
  from iris_core.engine.compiler import PolicyCompiler, CompilationResult
@@ -44,7 +47,7 @@ from iris_core.evidence.vault import EvidenceVault
44
47
  from iris_core.cost.tracker import CostSummary, CostTracker, CostEntry
45
48
  from iris_core.cost.pricing import PricingRegistry
46
49
 
47
- __version__ = "0.1.9"
50
+ __version__ = "0.2.0"
48
51
  __all__ = [
49
52
  # Main classes
50
53
  "IrisAgent",
@@ -73,6 +76,11 @@ __all__ = [
73
76
  "PricingRegistry",
74
77
  "IrisViolationError",
75
78
  "IrisCrisisDetectedError",
79
+ "IrisHITLRequiredError",
80
+ "HITLConfig",
81
+ "HITLConditionRule",
82
+ "HITLStatus",
83
+ "HITLPoller",
76
84
  ]
77
85
 
78
86
 
@@ -289,8 +297,11 @@ class IrisViolationError(Exception):
289
297
  explanation of what was blocked and how to remediate.
290
298
  """
291
299
 
292
- def __init__(self, result: PolicyResult):
300
+ def __init__(self, result: PolicyResult, is_compliance_block: bool = False):
293
301
  self.result = result
302
+ self.is_compliance_block = is_compliance_block or getattr(
303
+ result, "is_compliance_block", False
304
+ )
294
305
  primary = result.violations[0] if result.violations else None
295
306
  message = (
296
307
  f"\n[IRIS POLICY VIOLATION]\n"
@@ -0,0 +1,81 @@
1
+ """HITL polling helper for application-layer wait loops."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import asyncio
6
+ import time
7
+ from typing import Callable, Optional
8
+
9
+ from iris_core.hitl.models import HITLStatus
10
+ from iris_core.hitl.queue import HITLQueue
11
+
12
+
13
+ class HITLPoller:
14
+ """
15
+ Helper for applications that need to poll for HITL resolution.
16
+ Handles the polling loop, timeout, and retry logic.
17
+ """
18
+
19
+ def __init__(self, review_id: str, queue: Optional[HITLQueue] = None):
20
+ self.review_id = review_id
21
+ self._queue = queue or HITLQueue()
22
+
23
+ def wait(
24
+ self,
25
+ timeout: int = 300,
26
+ poll_interval: int = 5,
27
+ on_status_change: Optional[Callable[[HITLStatus], None]] = None,
28
+ ) -> HITLStatus:
29
+ deadline = time.time() + timeout
30
+ last_status: Optional[HITLStatus] = None
31
+ while time.time() < deadline:
32
+ review = self._queue.get(self.review_id)
33
+ if review is None:
34
+ time.sleep(poll_interval)
35
+ continue
36
+ if review.status != last_status:
37
+ if on_status_change:
38
+ on_status_change(review.status)
39
+ last_status = review.status
40
+ if review.status in (
41
+ HITLStatus.APPROVED,
42
+ HITLStatus.REJECTED,
43
+ HITLStatus.TIMED_OUT,
44
+ HITLStatus.ESCALATED,
45
+ ):
46
+ return review.status
47
+ if self._queue.is_expired(review):
48
+ resolved = self._queue.apply_timeout_policy(review)
49
+ return resolved.status
50
+ time.sleep(poll_interval)
51
+ return HITLStatus.TIMED_OUT
52
+
53
+ async def wait_async(
54
+ self,
55
+ timeout: int = 300,
56
+ poll_interval: int = 5,
57
+ on_status_change: Optional[Callable[[HITLStatus], None]] = None,
58
+ ) -> HITLStatus:
59
+ deadline = time.time() + timeout
60
+ last_status: Optional[HITLStatus] = None
61
+ while time.time() < deadline:
62
+ review = self._queue.get(self.review_id)
63
+ if review is None:
64
+ await asyncio.sleep(poll_interval)
65
+ continue
66
+ if review.status != last_status:
67
+ if on_status_change:
68
+ on_status_change(review.status)
69
+ last_status = review.status
70
+ if review.status in (
71
+ HITLStatus.APPROVED,
72
+ HITLStatus.REJECTED,
73
+ HITLStatus.TIMED_OUT,
74
+ HITLStatus.ESCALATED,
75
+ ):
76
+ return review.status
77
+ if self._queue.is_expired(review):
78
+ resolved = self._queue.apply_timeout_policy(review)
79
+ return resolved.status
80
+ await asyncio.sleep(poll_interval)
81
+ return HITLStatus.TIMED_OUT
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: iris-security-sdk
3
- Version: 0.1.9
3
+ Version: 0.2.0
4
4
  Summary: IRIS — AI Agent Governance SDK. Govern AI agents locally.
5
5
  License: Apache-2.0
6
6
  Project-URL: Homepage, https://github.com/gimartinb/iris-sdk
@@ -16,7 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
- Requires-Dist: iris-security-core>=0.1.7
19
+ Requires-Dist: iris-security-core>=0.1.8
20
20
  Requires-Dist: pyyaml>=6.0
21
21
  Requires-Dist: pydantic>=2.0
22
22
  Requires-Dist: click>=8.1
@@ -3,6 +3,7 @@ pyproject.toml
3
3
  iris/__init__.py
4
4
  iris/_telemetry.py
5
5
  iris/_telemetry_config.py
6
+ iris/hitl.py
6
7
  iris_security_sdk.egg-info/PKG-INFO
7
8
  iris_security_sdk.egg-info/SOURCES.txt
8
9
  iris_security_sdk.egg-info/dependency_links.txt
@@ -1,4 +1,4 @@
1
- iris-security-core>=0.1.7
1
+ iris-security-core>=0.1.8
2
2
  pyyaml>=6.0
3
3
  pydantic>=2.0
4
4
  click>=8.1
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "iris-security-sdk"
7
- version = "0.1.9"
7
+ version = "0.2.0"
8
8
  description = "IRIS — AI Agent Governance SDK. Govern AI agents locally."
9
9
  readme = "README.md"
10
10
  license = { text = "Apache-2.0" }
@@ -28,7 +28,7 @@ classifiers = [
28
28
  "Programming Language :: Python :: 3.12",
29
29
  ]
30
30
  dependencies = [
31
- "iris-security-core>=0.1.7",
31
+ "iris-security-core>=0.1.8",
32
32
  "pyyaml>=6.0",
33
33
  "pydantic>=2.0",
34
34
  "click>=8.1",