tryratify 0.1.0__py3-none-any.whl

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.
ratify_sdk/__init__.py ADDED
@@ -0,0 +1,4 @@
1
+ from .client import RatifyClient
2
+ from .guard import Guard, ToolRegistration, guarded_dispatch
3
+
4
+ __all__ = ["Guard", "RatifyClient", "ToolRegistration", "guarded_dispatch"]
ratify_sdk/cli.py ADDED
@@ -0,0 +1,63 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import os
5
+ import shutil
6
+ import subprocess # nosec B404 - starts the explicit local Ratify Client binary
7
+ from pathlib import Path
8
+
9
+
10
+ def parser() -> argparse.ArgumentParser:
11
+ root = argparse.ArgumentParser(prog="ratify")
12
+ commands = root.add_subparsers(dest="command", required=True)
13
+ client = commands.add_parser("client")
14
+ client_commands = client.add_subparsers(dest="client_command", required=True)
15
+ start = client_commands.add_parser("start")
16
+ start.add_argument("--cloud-url", required=True)
17
+ start.add_argument("--api-key", required=True)
18
+ start.add_argument("--agent-id", required=True)
19
+ start.add_argument("--client-id", default="client-local")
20
+ start.add_argument("--addr", default=":8088")
21
+ start.add_argument("--state-dir", default=".ratify")
22
+ return root
23
+
24
+
25
+ def main(argv: list[str] | None = None) -> int:
26
+ args = parser().parse_args(argv)
27
+ if args.command == "client" and args.client_command == "start":
28
+ state = Path(args.state_dir)
29
+ state.mkdir(parents=True, exist_ok=True)
30
+ command, cwd = _sidecar_command()
31
+ command.extend(
32
+ [
33
+ "-addr", args.addr,
34
+ "-cloud_url", args.cloud_url,
35
+ "-api_key", args.api_key,
36
+ "-agent_id", args.agent_id,
37
+ "-client_id", args.client_id,
38
+ "-rule_cache", str(state / "rules.json"),
39
+ "-audit_wal_path", str(state / "audit.wal"),
40
+ ]
41
+ )
42
+ return subprocess.call(command, cwd=cwd) # nosec B603 - fixed executable and parsed arguments
43
+ return 2
44
+
45
+
46
+ def _sidecar_command() -> tuple[list[str], Path | None]:
47
+ configured = os.environ.get("RATIFY_CLIENT_BINARY")
48
+ if configured:
49
+ return [configured], None
50
+ installed = shutil.which("ratify-sidecar")
51
+ if installed:
52
+ return [installed], None
53
+ repo = Path(__file__).resolve().parents[3]
54
+ if (repo / "cmd" / "sidecar" / "main.go").exists() and shutil.which("go"):
55
+ return ["go", "run", "./cmd/sidecar"], repo
56
+ raise SystemExit(
57
+ "Ratify Client binary was not found. Install ratify-sidecar or set "
58
+ "RATIFY_CLIENT_BINARY. Repository development also requires Go."
59
+ )
60
+
61
+
62
+ if __name__ == "__main__":
63
+ raise SystemExit(main())
ratify_sdk/client.py ADDED
@@ -0,0 +1,125 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from typing import Any
5
+
6
+ import requests
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class EvaluateResponse:
11
+ decision: str
12
+ reason: str
13
+ policy_triggered: str
14
+ trace_id: str
15
+ request_id: str
16
+ policy_id: str
17
+ risk_score: float
18
+ decided_at: str
19
+ approval_id: str | None = None
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class ApprovalWaitResponse:
24
+ approval_id: str
25
+ status: str
26
+ approver: str | None = None
27
+ resolved_at: str | None = None
28
+ reason: str | None = None
29
+
30
+
31
+ class RatifyClient:
32
+ def __init__(self, sidecar_url: str = "http://localhost:8080", timeout: float = 5.0) -> None:
33
+ self.sidecar_url = sidecar_url.rstrip("/")
34
+ self.timeout = timeout
35
+
36
+ def evaluate_tool_call(
37
+ self,
38
+ *,
39
+ agent_id: str,
40
+ session_id: str,
41
+ tool_name: str,
42
+ tool_type: str,
43
+ tool_input: dict[str, Any],
44
+ reasoning: str | None = None,
45
+ preceding_tool_calls: list[dict[str, str]] | None = None,
46
+ ) -> EvaluateResponse:
47
+ payload: dict[str, Any] = {
48
+ "agent_id": agent_id,
49
+ "session_id": session_id,
50
+ "tool_name": tool_name,
51
+ "tool_type": tool_type,
52
+ "tool_input": tool_input,
53
+ "preceding_tool_calls": preceding_tool_calls or [],
54
+ }
55
+ if reasoning:
56
+ payload["reasoning"] = reasoning
57
+ response = requests.post(
58
+ f"{self.sidecar_url}/v1/tool-call/evaluate",
59
+ json=payload,
60
+ timeout=self.timeout,
61
+ )
62
+ response.raise_for_status()
63
+ data = response.json()
64
+ return EvaluateResponse(
65
+ decision=data["decision"],
66
+ reason=data.get("reason", ""),
67
+ policy_triggered=data.get("policy_triggered", ""),
68
+ approval_id=data.get("approval_id"),
69
+ trace_id=data.get("trace_id", ""),
70
+ request_id=data.get("request_id", data.get("trace_id", "")),
71
+ policy_id=data.get("policy_id", data.get("policy_triggered", "")),
72
+ risk_score=float(data.get("risk_score", 0.0) or 0.0),
73
+ decided_at=data.get("decided_at", ""),
74
+ )
75
+
76
+ def wait_for_approval(self, approval_id: str) -> ApprovalWaitResponse:
77
+ # The server's single global held-call timeout bounds this long poll.
78
+ response = requests.get( # nosec B113
79
+ f"{self.sidecar_url}/v1/approval/{approval_id}/wait",
80
+ timeout=(self.timeout, None),
81
+ )
82
+ response.raise_for_status()
83
+ data = response.json()
84
+ return ApprovalWaitResponse(
85
+ approval_id=data.get("approval_id", approval_id),
86
+ status=data.get("status", ""),
87
+ approver=data.get("approver"),
88
+ resolved_at=data.get("resolved_at"),
89
+ reason=data.get("reason"),
90
+ )
91
+
92
+ def record_tool_execution(
93
+ self,
94
+ *,
95
+ agent_id: str,
96
+ session_id: str,
97
+ tool_name: str,
98
+ tool_type: str,
99
+ tool_input: dict[str, Any],
100
+ trace_id: str,
101
+ approval_id: str,
102
+ approver: str | None = None,
103
+ reasoning: str | None = None,
104
+ outcome: str = "delegated",
105
+ ) -> None:
106
+ payload: dict[str, Any] = {
107
+ "agent_id": agent_id,
108
+ "session_id": session_id,
109
+ "tool_name": tool_name,
110
+ "tool_type": tool_type,
111
+ "tool_input": tool_input,
112
+ "trace_id": trace_id,
113
+ "approval_id": approval_id,
114
+ "outcome": outcome,
115
+ }
116
+ if approver:
117
+ payload["approver"] = approver
118
+ if reasoning:
119
+ payload["reasoning"] = reasoning
120
+ response = requests.post(
121
+ f"{self.sidecar_url}/v1/tool-call/executed",
122
+ json=payload,
123
+ timeout=self.timeout,
124
+ )
125
+ response.raise_for_status()
ratify_sdk/guard.py ADDED
@@ -0,0 +1,281 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ import uuid
5
+ from dataclasses import dataclass
6
+ from typing import Any, Callable, Mapping
7
+
8
+ from .client import EvaluateResponse, RatifyClient
9
+
10
+ ToolFunc = Callable[..., Any]
11
+ ApprovalCallback = Callable[[dict[str, Any]], None]
12
+ TOOL_TYPES = {"file", "shell", "http", "database", "custom", "discovery"}
13
+
14
+
15
+ @dataclass(frozen=True)
16
+ class ToolRegistration:
17
+ func: ToolFunc
18
+ tool_type: str = "custom"
19
+
20
+
21
+ class Guard:
22
+ def __init__(
23
+ self,
24
+ *,
25
+ agent_id: str,
26
+ session_id: str | None = None,
27
+ sidecar_url: str = "http://localhost:8080",
28
+ timeout: float = 5.0,
29
+ approval_callback: ApprovalCallback | None = None,
30
+ client: RatifyClient | None = None,
31
+ ) -> None:
32
+ self.agent_id = agent_id
33
+ self.session_id = session_id or f"sess_{uuid.uuid4().hex[:12]}"
34
+ self.client = client or RatifyClient(sidecar_url=sidecar_url, timeout=timeout)
35
+ self.approval_callback = approval_callback
36
+ self.preceding_tool_calls: list[dict[str, str]] = []
37
+
38
+ def wrap(
39
+ self,
40
+ tools: Mapping[str, ToolFunc | ToolRegistration],
41
+ *,
42
+ tool_types: Mapping[str, str] | None = None,
43
+ ) -> "GuardedTools":
44
+ registrations: dict[str, ToolRegistration] = {}
45
+ tool_types = tool_types or {}
46
+ for name, value in tools.items():
47
+ if isinstance(value, ToolRegistration):
48
+ registrations[name] = value
49
+ else:
50
+ inferred_type = name.split(".", 1)[0] if "." in name else "custom"
51
+ registrations[name] = ToolRegistration(
52
+ value,
53
+ tool_types.get(name, inferred_type if inferred_type in TOOL_TYPES else "custom"),
54
+ )
55
+ return GuardedTools(self, registrations)
56
+
57
+ def dispatch(
58
+ self,
59
+ tool_use: Mapping[str, Any],
60
+ tools: Mapping[str, ToolFunc | ToolRegistration],
61
+ *,
62
+ tool_types: Mapping[str, str] | None = None,
63
+ reasoning: str | None = None,
64
+ ) -> dict[str, Any]:
65
+ return self.wrap(tools, tool_types=tool_types).dispatch(
66
+ tool_use,
67
+ reasoning=reasoning,
68
+ )
69
+
70
+
71
+ class GuardedTools:
72
+ def __init__(self, guard: Guard, tools: Mapping[str, ToolRegistration]) -> None:
73
+ self.guard = guard
74
+ self.tools = dict(tools)
75
+
76
+ def dispatch(
77
+ self,
78
+ tool_use: Mapping[str, Any],
79
+ *,
80
+ reasoning: str | None = None,
81
+ ) -> dict[str, Any]:
82
+ tool_name = str(tool_use.get("name", ""))
83
+ if tool_name not in self.tools:
84
+ return _tool_result(tool_use, {"status": "error", "reason": f"unknown tool {tool_name!r}"}, is_error=True)
85
+ registration = self.tools[tool_name]
86
+ tool_input = dict(tool_use.get("input") or {})
87
+ decision = self.guard.client.evaluate_tool_call(
88
+ agent_id=self.guard.agent_id,
89
+ session_id=self.guard.session_id,
90
+ tool_name=tool_name,
91
+ tool_type=registration.tool_type,
92
+ tool_input=tool_input,
93
+ reasoning=reasoning,
94
+ preceding_tool_calls=list(self.guard.preceding_tool_calls),
95
+ )
96
+ self.guard.preceding_tool_calls.append(
97
+ {
98
+ "tool_name": tool_name,
99
+ "tool_type": registration.tool_type,
100
+ "decision": decision.decision,
101
+ "request_id": decision.request_id,
102
+ "policy_id": decision.policy_id,
103
+ "risk_score": f"{decision.risk_score:.2f}",
104
+ "decided_at": decision.decided_at,
105
+ }
106
+ )
107
+ if decision.decision == "delegated":
108
+ return self._execute_tool(tool_use, registration, tool_input)
109
+ if decision.decision == "reserved":
110
+ return _tool_result(tool_use, _blocked_payload(decision), is_error=True)
111
+ if decision.decision == "requires_approval":
112
+ return self._wait_for_approval_and_maybe_execute(
113
+ tool_use,
114
+ registration,
115
+ tool_input,
116
+ reasoning,
117
+ decision,
118
+ )
119
+ return _tool_result(
120
+ tool_use,
121
+ {"status": "error", "reason": f"unknown Ratify decision {decision.decision!r}"},
122
+ is_error=True,
123
+ )
124
+
125
+ def _execute_tool(
126
+ self,
127
+ tool_use: Mapping[str, Any],
128
+ registration: ToolRegistration,
129
+ tool_input: dict[str, Any],
130
+ ) -> dict[str, Any]:
131
+ try:
132
+ result = registration.func(**tool_input)
133
+ except Exception as exc:
134
+ return _tool_result(tool_use, _tool_execution_error_payload(exc), is_error=True)
135
+ return _tool_result(tool_use, result)
136
+
137
+ def _wait_for_approval_and_maybe_execute(
138
+ self,
139
+ tool_use: Mapping[str, Any],
140
+ registration: ToolRegistration,
141
+ tool_input: dict[str, Any],
142
+ reasoning: str | None,
143
+ decision: EvaluateResponse,
144
+ ) -> dict[str, Any]:
145
+ if not decision.approval_id:
146
+ return _tool_result(tool_use, {"status": "approval_error", "reason": "missing approval_id"}, is_error=True)
147
+ self._approval_event(
148
+ {
149
+ "event": "required",
150
+ "approval_id": decision.approval_id,
151
+ "reason": decision.reason,
152
+ "policy_triggered": decision.policy_triggered,
153
+ "policy_id": decision.policy_id,
154
+ "risk_score": decision.risk_score,
155
+ "trace_id": decision.trace_id,
156
+ "request_id": decision.request_id,
157
+ "tool_name": tool_use.get("name", ""),
158
+ }
159
+ )
160
+ wait = self.guard.client.wait_for_approval(decision.approval_id)
161
+ self._approval_event(
162
+ {
163
+ "event": "timeout_reserved" if wait.reason == "held_call_timeout" else wait.status,
164
+ "approval_id": decision.approval_id,
165
+ "approver": wait.approver,
166
+ "resolved_at": wait.resolved_at,
167
+ "reason": wait.reason,
168
+ }
169
+ )
170
+ if wait.status == "delegated":
171
+ result = self._execute_tool(tool_use, registration, tool_input)
172
+ self.guard.client.record_tool_execution(
173
+ agent_id=self.guard.agent_id,
174
+ session_id=self.guard.session_id,
175
+ tool_name=str(tool_use.get("name", "")),
176
+ tool_type=registration.tool_type,
177
+ tool_input=tool_input,
178
+ trace_id=decision.trace_id,
179
+ approval_id=decision.approval_id,
180
+ approver=wait.approver,
181
+ reasoning=reasoning,
182
+ )
183
+ return result
184
+ if wait.status == "reserved" and wait.reason == "human_reserved":
185
+ self.guard.client.record_tool_execution(
186
+ agent_id=self.guard.agent_id,
187
+ session_id=self.guard.session_id,
188
+ tool_name=str(tool_use.get("name", "")),
189
+ tool_type=registration.tool_type,
190
+ tool_input=tool_input,
191
+ trace_id=decision.trace_id,
192
+ approval_id=decision.approval_id,
193
+ approver=wait.approver,
194
+ reasoning=reasoning,
195
+ outcome="reserved",
196
+ )
197
+ return _tool_result(tool_use, _human_reserved_payload(wait.approver, decision.reason), is_error=True)
198
+ return _tool_result(tool_use, _held_call_timeout_payload(), is_error=True)
199
+
200
+ def _approval_event(self, event: dict[str, Any]) -> None:
201
+ if self.guard.approval_callback is not None:
202
+ self.guard.approval_callback(event)
203
+
204
+
205
+ def guarded_dispatch(
206
+ tool_use: Mapping[str, Any],
207
+ tools: Mapping[str, ToolFunc | ToolRegistration],
208
+ *,
209
+ agent_id: str,
210
+ session_id: str | None = None,
211
+ tool_types: Mapping[str, str] | None = None,
212
+ sidecar_url: str = "http://localhost:8080",
213
+ reasoning: str | None = None,
214
+ ) -> dict[str, Any]:
215
+ guard = Guard(agent_id=agent_id, session_id=session_id, sidecar_url=sidecar_url)
216
+ return guard.dispatch(tool_use, tools, tool_types=tool_types, reasoning=reasoning)
217
+
218
+
219
+ def _tool_result(tool_use: Mapping[str, Any], content: Any, *, is_error: bool = False) -> dict[str, Any]:
220
+ result = {
221
+ "type": "tool_result",
222
+ "tool_use_id": tool_use.get("id", ""),
223
+ "content": json.dumps(content, sort_keys=True),
224
+ }
225
+ if is_error:
226
+ result["is_error"] = True
227
+ return result
228
+
229
+
230
+ def _blocked_payload(decision: EvaluateResponse) -> dict[str, Any]:
231
+ return {
232
+ "status": "reserved",
233
+ "message": "This tool call is Reserved and was not executed. Choose a delegated alternative or explain the authority boundary.",
234
+ "reason": decision.reason,
235
+ "policy_triggered": decision.policy_triggered,
236
+ "policy_id": decision.policy_id,
237
+ "risk_score": decision.risk_score,
238
+ "trace_id": decision.trace_id,
239
+ "request_id": decision.request_id,
240
+ }
241
+
242
+
243
+ def _pending_payload(decision: EvaluateResponse) -> dict[str, Any]:
244
+ return {
245
+ "status": "pending_approval",
246
+ "message": "Ratify parked this tool call for human approval. Do not retry the same action while it is pending; continue with safe non-sensitive work or tell the user approval is required.",
247
+ "reason": decision.reason,
248
+ "approval_id": decision.approval_id,
249
+ "policy_triggered": decision.policy_triggered,
250
+ "policy_id": decision.policy_id,
251
+ "risk_score": decision.risk_score,
252
+ "trace_id": decision.trace_id,
253
+ "request_id": decision.request_id,
254
+ }
255
+
256
+
257
+ def _human_reserved_payload(approver: str | None, reason: str | None) -> dict[str, Any]:
258
+ return {
259
+ "status": "reserved",
260
+ "reason": "human_reserved",
261
+ "message": "The reviewing principal kept this call Reserved.",
262
+ "approver": approver,
263
+ "rule": reason or "",
264
+ }
265
+
266
+
267
+ def _held_call_timeout_payload() -> dict[str, Any]:
268
+ return {
269
+ "status": "reserved",
270
+ "reason": "held_call_timeout",
271
+ "message": "The global held-call timeout elapsed. The tool remained reserved and was not executed.",
272
+ }
273
+
274
+
275
+ def _tool_execution_error_payload(exc: Exception) -> dict[str, Any]:
276
+ return {
277
+ "status": "tool_execution_failed",
278
+ "message": "Ratify delegated this tool call, but the tool failed during execution. Use this failure to choose another safe path or tell the user the dependency is unavailable.",
279
+ "error_type": exc.__class__.__name__,
280
+ "reason": str(exc),
281
+ }
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: tryratify
3
+ Version: 0.1.0
4
+ Summary: Local authority enforcement client for Ratify
5
+ Author: Ratify contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://tryratify.com
8
+ Project-URL: Documentation, https://github.com/ratify-ai/ratify/tree/main/docs
9
+ Project-URL: Source, https://github.com/ratify-ai/ratify
10
+ Project-URL: Issues, https://github.com/ratify-ai/ratify/issues
11
+ Keywords: ai-agents,authority,approval,audit,policy
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: requests<3,>=2.32
27
+ Provides-Extra: dev
28
+ Requires-Dist: pytest>=8; extra == "dev"
29
+ Dynamic: license-file
30
+
31
+ # Ratify
32
+
33
+ Ratify is an authority control plane for AI agents. You define which tool calls
34
+ an agent may execute autonomously, which require another principal's approval,
35
+ and which remain reserved.
36
+
37
+ Ratify Cloud owns Authority Grants, approvals, client identity, and uploaded
38
+ audit records. Ratify Client runs beside the agent, synchronizes versioned rules,
39
+ evaluates tool calls locally, and uploads audit batches asynchronously. Normal
40
+ tool evaluation does not require a per-call Cloud round trip.
41
+
42
+ See [Ratify v1 architecture](docs/architecture.md) for the lifecycle and stale
43
+ rules behavior.
44
+
45
+ Authority decisions use three terms:
46
+
47
+ - **Delegated**: the agent may execute the action.
48
+ - **Requires Approval**: execution waits for a Cloud reviewer.
49
+ - **Reserved**: the agent may not execute the action.
50
+
51
+ ## Install
52
+
53
+ The Python distribution is `tryratify`; it installs the `ratify` command:
54
+
55
+ ```bash
56
+ python -m pip install tryratify
57
+ ratify --help
58
+ ```
59
+
60
+ Until the first PyPI release, install it from a source checkout:
61
+
62
+ ```bash
63
+ git clone https://github.com/ratify-ai/ratify.git
64
+ cd ratify
65
+ python -m pip install .
66
+ go build -o ratify-sidecar ./cmd/sidecar
67
+ export RATIFY_CLIENT_BINARY="$PWD/ratify-sidecar"
68
+ ```
69
+
70
+ The Python package contains the SDK and CLI. `ratify client start` also requires
71
+ the separately built or installed `ratify-sidecar` binary.
72
+
73
+ ## Create an API key
74
+
75
+ Sign up at [tryratify.com/signup](https://tryratify.com/signup). Signup creates
76
+ an account, a default agent, and an API key. Copy the key when it appears; its
77
+ secret is shown only once.
78
+
79
+ For local development, start Ratify Cloud and use its signup page:
80
+
81
+ ```bash
82
+ go run ./cmd/cloud -addr :8090 -data .ratify/cloud.json
83
+ ```
84
+
85
+ Open [http://127.0.0.1:8090/signup](http://127.0.0.1:8090/signup). Additional
86
+ keys can be created or revoked from **API Keys**.
87
+
88
+ ## Start Ratify Client
89
+
90
+ Use the Cloud URL, API key, and agent ID shown during onboarding:
91
+
92
+ ```bash
93
+ ratify client start \
94
+ --cloud-url https://tryratify.com \
95
+ --api-key '<copied-key>' \
96
+ --agent-id '<agent-id>' \
97
+ --client-id client-local
98
+ ```
99
+
100
+ For local Cloud, replace the Cloud URL with `http://127.0.0.1:8090`. The client
101
+ listens at `http://127.0.0.1:8088` by default. The Cloud **Clients** page shows
102
+ its heartbeat, current ruleset version, latest published version, account state,
103
+ and quota state.
104
+
105
+ ## Publish an authority rule
106
+
107
+ Open **Authority Grants**, publish YAML using the exact fully qualified tool
108
+ names used by your agent, and wait for the client version to match the published
109
+ version:
110
+
111
+ ```yaml
112
+ agent: <agent-id>
113
+
114
+ rules:
115
+ - name: Read public data
116
+ tool: custom.read_data
117
+ condition: true
118
+ action: delegated
119
+
120
+ - name: Publish changes with review
121
+ tool: custom.publish_changes
122
+ condition: true
123
+ action: requires_approval
124
+
125
+ - name: Keep destructive operations reserved
126
+ tool: custom.destroy_system
127
+ condition: true
128
+ action: reserved
129
+ ```
130
+
131
+ Rule actions are exactly `delegated`, `requires_approval`, and `reserved`.
132
+
133
+ ## Run the first governed action
134
+
135
+ Wrap actual tool entrypoints with `Guard`. Use stable `namespace.action` names;
136
+ the same name must appear in the tool call and Authority Grants.
137
+
138
+ ```python
139
+ from ratify_sdk import Guard
140
+
141
+
142
+ def read_data(item: str) -> dict[str, str]:
143
+ return {"item": item, "value": "public"}
144
+
145
+
146
+ guard = Guard(
147
+ agent_id="<agent-id>",
148
+ sidecar_url="http://127.0.0.1:8088",
149
+ )
150
+ tools = guard.wrap({"custom.read_data": read_data})
151
+
152
+ result = tools.dispatch({
153
+ "id": "call-1",
154
+ "name": "custom.read_data",
155
+ "input": {"item": "launch-status"},
156
+ })
157
+ ```
158
+
159
+ A Delegated call executes locally. A Requires Approval call appears in Cloud
160
+ and resumes after review. A Reserved call is not executed. Each decision is
161
+ queued locally and uploaded to Cloud Audit.
162
+
163
+ ## Development
164
+
165
+ ```bash
166
+ go build ./...
167
+ go test ./...
168
+ python -m pip install -e '.[dev]'
169
+ python -m pytest sdk/python/tests
170
+ python -m build
171
+ ```
172
+
173
+ The optional customer-support demonstration is isolated under
174
+ [`examples/demo`](examples/demo/README.md) and is not part of the Ratify product
175
+ runtime or Python distribution.
176
+
177
+ Ratify is licensed under the [Apache License 2.0](LICENSE).
@@ -0,0 +1,10 @@
1
+ ratify_sdk/__init__.py,sha256=OQ6mODEC95u9qENkhluvtq4dUJKTeiicyrRYZ8rdXH0,171
2
+ ratify_sdk/cli.py,sha256=z3ACe0GMfVKPf5U2bkJEm2MUum2W8EntGGFgeh6qiJc,2329
3
+ ratify_sdk/client.py,sha256=PhChd1OMGLOAVRUH1QsnZbxtPNSYmoTu0fkXmiogXDQ,3896
4
+ ratify_sdk/guard.py,sha256=mXoQvXt2_qTxQyx62G-rSDuCP4XzvUeToXgsiP5o0NQ,10608
5
+ tryratify-0.1.0.dist-info/licenses/LICENSE,sha256=cuUfW1rl7i8ZE-TMOl1c-mrOtf-NGpbCtSLbIARYWKk,10246
6
+ tryratify-0.1.0.dist-info/METADATA,sha256=5cV6KZhu_fKyZmnKBSFvhWZCqRD5ASGUhScFZ178svs,5326
7
+ tryratify-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
8
+ tryratify-0.1.0.dist-info/entry_points.txt,sha256=IM4rSlsrylOYIDRVaa-mzByuuGnF8mJAkVAmeuAlqzY,47
9
+ tryratify-0.1.0.dist-info/top_level.txt,sha256=j_DXxvvS1lNVxFMlq0Pkae29GaPWQvULOkE2wPhR45g,11
10
+ tryratify-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ratify = ratify_sdk.cli:main
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work, excluding
103
+ those notices that do not pertain to any part of the
104
+ Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Ratify contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1 @@
1
+ ratify_sdk