kerneva-runtime-trust 0.3.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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Kerneva AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: kerneva-runtime-trust
3
+ Version: 0.3.0
4
+ Summary: Behavioral safety for financial AI agents
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/vaibhavdedhia/runtime-trust
7
+ Project-URL: Documentation, https://github.com/vaibhavdedhia/runtime-trust#readme
8
+ Project-URL: Repository, https://github.com/vaibhavdedhia/runtime-trust.git
9
+ Project-URL: Changelog, https://github.com/vaibhavdedhia/runtime-trust/blob/main/CHANGELOG.md
10
+ Project-URL: Issues, https://github.com/vaibhavdedhia/runtime-trust/issues
11
+ Keywords: ai-safety,llm,financial-agents,compliance
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Dynamic: license-file
23
+
24
+ # Kerneva Runtime Trust
25
+
26
+ Behavioral safety for financial AI agents.
27
+
28
+ ```python
29
+ from kerneva_runtime_trust import guard, RuntimeTrustBlock
30
+
31
+ @guard(action_type="refund")
32
+ def process_refund(amount, customer_id):
33
+ return billing_api.refund(customer_id, amount)
34
+
35
+ try:
36
+ process_refund(amount=150.0, customer_id="cust_123")
37
+ except RuntimeTrustBlock as e:
38
+ print(f"Blocked: {e}")
39
+ ```
40
+
41
+ `guard` (also available as `with_runtime_trust`) evaluates every call through
42
+ Kerneva's `/evaluate` before the function body runs. On `BLOCK` the function
43
+ never executes and `RuntimeTrustBlock` is raised.
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install kerneva-runtime-trust
49
+ ```
50
+
51
+ ## Setup
52
+
53
+ ```bash
54
+ export KERNEVA_API_KEY="krv_test_abc123"
55
+ export KERNEVA_API_URL="https://api.kerneva.com" # or http://localhost:8080
56
+ ```
57
+
58
+ ## Getting good signals
59
+
60
+ Kerneva reasons over an agent's *trajectory* — within a session and across your
61
+ end-customers. A single function call doesn't carry that context, so declare it.
62
+ The two that matter most:
63
+
64
+ - **`action_type`** — match a configured threshold (e.g. `"refund"`). If it has
65
+ no threshold the call is observation-only; the SDK logs a warning so you know.
66
+ - **`customer_id`** — the end-customer, so one customer's trajectory doesn't
67
+ bleed into another's.
68
+
69
+ Set them per-call, or ambiently for a whole interaction with `session(...)`:
70
+
71
+ ```python
72
+ import kerneva_runtime_trust as kerneva
73
+
74
+ with kerneva.session(session_id=ticket_id, agent_id="refund-bot",
75
+ customer_id="cust_123"):
76
+ process_refund(amount=40.0, customer_id="cust_123")
77
+ process_refund(amount=75.0, customer_id="cust_123") # shares one trajectory
78
+ ```
79
+
80
+ Without a session, each call gets its own session id (so unrelated calls are
81
+ never merged) and the SDK warns once that session-scoped analysis is off.
82
+
83
+ ## Handling REVIEW
84
+
85
+ By default a `REVIEW` decision emits a Python warning and proceeds. To route it
86
+ to a human (hold, queue, escalate), pass an `on_review` hook — it may raise to
87
+ halt execution:
88
+
89
+ ```python
90
+ def hold_for_approval(ctx):
91
+ if ctx.recommended_decision == "REVIEW":
92
+ raise NeedsApproval(ctx.reason) # stops the wrapped function
93
+
94
+ @guard(action_type="refund", on_review=hold_for_approval)
95
+ def process_refund(amount, customer_id): ...
96
+ ```
97
+
98
+ ## Reliability
99
+
100
+ - **Fail-closed by default:** if the API is unreachable the action does not run.
101
+ Pass `fail_open=True` for non-critical workflows.
102
+ - **`strict=True`** turns integration warnings (misconfiguration) into a raised
103
+ `KernevaConfigError` — useful in development/CI to catch a broken integration.
104
+ - **Async:** decorating an `async def` returns an async wrapper.
105
+
106
+ ## Low-level client
107
+
108
+ ```python
109
+ from kerneva_runtime_trust import KernevaClient
110
+
111
+ client = KernevaClient(api_key="krv_test_abc123")
112
+ result = client.evaluate(
113
+ agent_id="refund-bot", session_id="ticket-8842",
114
+ action_type="refund", amount=82.0, customer_id="cust_123",
115
+ )
116
+ # In Observation Mode nothing is blocked; recommended_decision is the shadow
117
+ # verdict — what enforcement WOULD do.
118
+ print(result.decision, result.recommended_decision, result.warnings)
119
+ ```
120
+
121
+ See https://github.com/kerneva/runtime-trust for full documentation.
@@ -0,0 +1,98 @@
1
+ # Kerneva Runtime Trust
2
+
3
+ Behavioral safety for financial AI agents.
4
+
5
+ ```python
6
+ from kerneva_runtime_trust import guard, RuntimeTrustBlock
7
+
8
+ @guard(action_type="refund")
9
+ def process_refund(amount, customer_id):
10
+ return billing_api.refund(customer_id, amount)
11
+
12
+ try:
13
+ process_refund(amount=150.0, customer_id="cust_123")
14
+ except RuntimeTrustBlock as e:
15
+ print(f"Blocked: {e}")
16
+ ```
17
+
18
+ `guard` (also available as `with_runtime_trust`) evaluates every call through
19
+ Kerneva's `/evaluate` before the function body runs. On `BLOCK` the function
20
+ never executes and `RuntimeTrustBlock` is raised.
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install kerneva-runtime-trust
26
+ ```
27
+
28
+ ## Setup
29
+
30
+ ```bash
31
+ export KERNEVA_API_KEY="krv_test_abc123"
32
+ export KERNEVA_API_URL="https://api.kerneva.com" # or http://localhost:8080
33
+ ```
34
+
35
+ ## Getting good signals
36
+
37
+ Kerneva reasons over an agent's *trajectory* — within a session and across your
38
+ end-customers. A single function call doesn't carry that context, so declare it.
39
+ The two that matter most:
40
+
41
+ - **`action_type`** — match a configured threshold (e.g. `"refund"`). If it has
42
+ no threshold the call is observation-only; the SDK logs a warning so you know.
43
+ - **`customer_id`** — the end-customer, so one customer's trajectory doesn't
44
+ bleed into another's.
45
+
46
+ Set them per-call, or ambiently for a whole interaction with `session(...)`:
47
+
48
+ ```python
49
+ import kerneva_runtime_trust as kerneva
50
+
51
+ with kerneva.session(session_id=ticket_id, agent_id="refund-bot",
52
+ customer_id="cust_123"):
53
+ process_refund(amount=40.0, customer_id="cust_123")
54
+ process_refund(amount=75.0, customer_id="cust_123") # shares one trajectory
55
+ ```
56
+
57
+ Without a session, each call gets its own session id (so unrelated calls are
58
+ never merged) and the SDK warns once that session-scoped analysis is off.
59
+
60
+ ## Handling REVIEW
61
+
62
+ By default a `REVIEW` decision emits a Python warning and proceeds. To route it
63
+ to a human (hold, queue, escalate), pass an `on_review` hook — it may raise to
64
+ halt execution:
65
+
66
+ ```python
67
+ def hold_for_approval(ctx):
68
+ if ctx.recommended_decision == "REVIEW":
69
+ raise NeedsApproval(ctx.reason) # stops the wrapped function
70
+
71
+ @guard(action_type="refund", on_review=hold_for_approval)
72
+ def process_refund(amount, customer_id): ...
73
+ ```
74
+
75
+ ## Reliability
76
+
77
+ - **Fail-closed by default:** if the API is unreachable the action does not run.
78
+ Pass `fail_open=True` for non-critical workflows.
79
+ - **`strict=True`** turns integration warnings (misconfiguration) into a raised
80
+ `KernevaConfigError` — useful in development/CI to catch a broken integration.
81
+ - **Async:** decorating an `async def` returns an async wrapper.
82
+
83
+ ## Low-level client
84
+
85
+ ```python
86
+ from kerneva_runtime_trust import KernevaClient
87
+
88
+ client = KernevaClient(api_key="krv_test_abc123")
89
+ result = client.evaluate(
90
+ agent_id="refund-bot", session_id="ticket-8842",
91
+ action_type="refund", amount=82.0, customer_id="cust_123",
92
+ )
93
+ # In Observation Mode nothing is blocked; recommended_decision is the shadow
94
+ # verdict — what enforcement WOULD do.
95
+ print(result.decision, result.recommended_decision, result.warnings)
96
+ ```
97
+
98
+ See https://github.com/kerneva/runtime-trust for full documentation.
@@ -0,0 +1,43 @@
1
+ from .client import KernevaClient
2
+ from .context import (
3
+ current_agent_id,
4
+ current_customer_id,
5
+ current_metadata,
6
+ current_session_id,
7
+ new_session_id,
8
+ session,
9
+ )
10
+ from .exceptions import KernevaBlocked, KernevaError
11
+ from .models import (
12
+ AgentSummary,
13
+ EvaluationDetail,
14
+ EvaluationResult,
15
+ ExecutionOutcome,
16
+ HistoryEntry,
17
+ SignalEntry,
18
+ TraceEntry,
19
+ )
20
+ from .runtime_trust import ReviewContext, RuntimeTrustBlock, guard, with_runtime_trust
21
+
22
+ __all__ = [
23
+ "with_runtime_trust",
24
+ "guard",
25
+ "RuntimeTrustBlock",
26
+ "ReviewContext",
27
+ "session",
28
+ "new_session_id",
29
+ "current_agent_id",
30
+ "current_session_id",
31
+ "current_customer_id",
32
+ "current_metadata",
33
+ "KernevaClient",
34
+ "KernevaError",
35
+ "KernevaBlocked",
36
+ "EvaluationResult",
37
+ "ExecutionOutcome",
38
+ "EvaluationDetail",
39
+ "HistoryEntry",
40
+ "AgentSummary",
41
+ "SignalEntry",
42
+ "TraceEntry",
43
+ ]