ctrlrun 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.
@@ -0,0 +1,164 @@
1
+ Metadata-Version: 2.4
2
+ Name: ctrlrun
3
+ Version: 0.1.0
4
+ Summary: Make consequential AI-agent actions safe to execute.
5
+ Author-email: Arpan Ghoshal <contact@arpanghoshal.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/CTRLRun/ctrlrun
8
+ Project-URL: Repository, https://github.com/CTRLRun/ctrlrun
9
+ Project-URL: Documentation, https://github.com/CTRLRun/ctrlrun/tree/main/docs
10
+ Project-URL: Changelog, https://github.com/CTRLRun/ctrlrun/blob/main/CHANGELOG.md
11
+ Project-URL: Issues, https://github.com/CTRLRun/ctrlrun/issues
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Typing :: Typed
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: pyyaml
21
+ Requires-Dist: click
22
+ Provides-Extra: dev
23
+ Requires-Dist: pytest>=8; extra == "dev"
24
+ Requires-Dist: mypy>=2.3; extra == "dev"
25
+ Requires-Dist: ruff>=0.16; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # CTRLRun
29
+
30
+ **Transaction safety for AI-agent actions.**
31
+
32
+ > Agents can retry. Your refund shouldn't.
33
+
34
+ CTRLRun is open-source infrastructure for controlling consequential AI-agent actions.
35
+
36
+ You decide, per action, what an agent can do autonomously, what requires human approval, and what is blocked.
37
+
38
+ CTRLRun binds approvals to the exact action, blocks duplicate execution attempts for the same logical effect, stops blind retries when an execution outcome is uncertain, and records what actually happened.
39
+
40
+ **Autonomy belongs to the action, not the agent.**
41
+
42
+ ---
43
+
44
+ ## The problem
45
+
46
+ Agents are getting write access to the real world: refunds, emails, deploys, permission grants, record changes. Frameworks already let you approve or deny a tool call. That is not the hard part.
47
+
48
+ The hard part is what happens at the boundary between *intention* and *effect*:
49
+
50
+ - A refund commits at Stripe, the response times out, the agent retries. **Did you just refund twice?**
51
+ - A human approves a €500 refund. The agent changes it to €5,000 before executing. **Should that approval still count?**
52
+ - Two agents pick up the same task and issue the same refund. **Which one wins?**
53
+ - A call timed out. Your framework marks it *failed* and retries. **It wasn't failed. It was unknown.**
54
+
55
+ CTRLRun owns that boundary.
56
+
57
+ ## Quick start
58
+
59
+ ```bash
60
+ pip install ctrlrun
61
+ ctrlrun demo
62
+ ```
63
+
64
+ `ctrlrun demo` runs the four failure scenarios below in well under a second, with no external services.
65
+
66
+ Protect your first action:
67
+
68
+ ```python
69
+ import ctrlrun
70
+
71
+
72
+ @ctrlrun.protect("stripe.refund", effect="refund:{payment_id}")
73
+ def refund(payment_id: str, amount: int, currency: str = "EUR"):
74
+ return stripe.refunds.create(payment_intent=payment_id, amount=amount)
75
+ ```
76
+
77
+ Configure autonomy per action in `ctrlrun.yaml`:
78
+
79
+ ```yaml
80
+ schema: ctrlrun.policy/v1
81
+
82
+ actions:
83
+ customer.read:
84
+ decision: allow
85
+
86
+ stripe.refund:
87
+ rules:
88
+ - when: { amount_gte: 0, amount_lte: 50000 } # up to €500.00
89
+ decision: allow
90
+ - when: { amount_gte: 0, amount_lte: 500000 } # up to €5,000.00
91
+ decision: approve
92
+ - decision: deny
93
+ ```
94
+
95
+ Amounts are integer minor units — cents, not euros. Floats are rejected outright, because `0.1` and `0.10` are the same money and different hashes.
96
+
97
+ Now the same agent can refund €100 on its own, must get a human to approve €2,000, and cannot refund €20,000 at all. Neither can it refund a negative amount, which is a charge wearing a refund's name — an upper bound alone is not a range. Unknown actions are denied. CTRLRun fails closed.
98
+
99
+ ## What `ctrlrun demo` shows
100
+
101
+ ```console
102
+ $ ctrlrun demo
103
+ CTRLRun demo — four ways an agent action goes wrong, and what stops it.
104
+ Policy: refunds up to €1,000 are autonomous, up to €10,000 need a human, above that are denied.
105
+
106
+ 1. Duplicate effect after a lost response
107
+
108
+ refund €500 → remote commits → response lost → effect: AMBIGUOUS
109
+ agent retries the same refund
110
+ ✗ BLOCKED — effect may already have committed; blind retry refused
111
+ remote refund calls: 1
112
+ only a human moves it on: ctrlrun resolve refund:txn_1 --committed|--failed
113
+
114
+ 2. Approval mutation
115
+
116
+ agent proposes refund €2,000 → human approves apr_0aa78e0380ba55d77a601dc782f57095 (bound to the action hash)
117
+ agent executes refund €5,000 →
118
+ ✗ BLOCKED — approved action ≠ requested action (mismatch)
119
+
120
+ 3. Concurrent agents, same effect
121
+
122
+ Agent A reserve refund:txn_123 → ACQUIRED → executes
123
+ Agent B reserve refund:txn_123 →
124
+ ✗ BLOCKED — already reserved (in_progress)
125
+
126
+ 4. Approval replay
127
+
128
+ approval apr_dbc8bc6f06690cdf2e2c55a4e591ef3b used once → consumed
129
+ same approval presented again →
130
+ ✗ BLOCKED — single-use approval already consumed
131
+
132
+ Receipts (7): .ctrlrun/demo/receipts.jsonl
133
+ Events: .ctrlrun/demo/events.jsonl
134
+
135
+ Read them: CTRLRUN_STATE=.ctrlrun/demo/state.db ctrlrun receipts
136
+ ```
137
+
138
+ Approval ids are generated per run; everything else is byte-for-byte what the demo prints.
139
+
140
+ Note scenario 1: **`remote refund calls: 1`**. The refund committed at the remote, the response was lost, and the retry was refused — so the customer was refunded once, not twice. Nothing but a human resolving the effect moves it on.
141
+
142
+ Every executed action produces a portable JSON receipt: who, what, arguments, decision, approval, effect key, and result (`committed`, `failed`, or `ambiguous`).
143
+
144
+ ## What CTRLRun is not
145
+
146
+ CTRLRun does not host models, plan, prompt, retrieve, route, remember, or orchestrate. It is not a guardrail library, an IAM system, a workflow engine, or a compliance product. If an agent only reads and answers, you don't need CTRLRun. The moment it can **send, pay, refund, delete, deploy, grant, revoke, approve, submit, purchase, or cancel**, you do.
147
+
148
+ CTRLRun cannot guarantee exactly-once execution against external systems it doesn't control. It guarantees that it will not *knowingly* execute the same logical effect twice, and that it will never treat an unknown outcome as a failure.
149
+
150
+ ## Documentation
151
+
152
+ | Doc | Purpose |
153
+ |---|---|
154
+ | [`docs/SPEC-v0.1.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/SPEC-v0.1.md) | The v0.1 contract: models, invariants, acceptance tests |
155
+ | [`docs/ARCHITECTURE.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/ARCHITECTURE.md) | Kernel design and key decisions |
156
+ | [`docs/ROADMAP.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/ROADMAP.md) | v0.1 → v1.0 |
157
+ | [`docs/THREAT_MODEL.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/THREAT_MODEL.md) | What CTRLRun defends against and what it doesn't |
158
+ | [`docs/CLAIMS.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/CLAIMS.md) | Every claim above, mapped to the code and the test that proves it |
159
+ | [`SECURITY.md`](https://github.com/CTRLRun/ctrlrun/blob/main/SECURITY.md) | Reporting a vulnerability |
160
+ | [`VISION.md`](https://github.com/CTRLRun/ctrlrun/blob/main/VISION.md) | Where this can go — not a build spec |
161
+
162
+ ## License
163
+
164
+ Apache-2.0. The enforcement kernel is and will remain fully open source.
@@ -0,0 +1,19 @@
1
+ ctrlrun/__init__.py,sha256=TkwFfBh-QA5cNBW_Yrn5X1S0ea6uMmlggwNGLo7WcWM,1538
2
+ ctrlrun/action.py,sha256=lL9s8I8Aa2bhz6SK-JH827x9Htm6InnGNNsM6izexfs,6081
3
+ ctrlrun/approval.py,sha256=e8KY5FxmKHZUa7kCQkWuYT4YCV_g9HcVKygBBZBvEPA,16840
4
+ ctrlrun/control.py,sha256=xM4A5tSGobQFNbCAfvS0Fyi_IYHbO3hVRGxQGvhszuU,33388
5
+ ctrlrun/effect.py,sha256=CSSOVeQrYlH9oaBw4ULWCTVmFE1ROeWlHJAOStYIH5U,12259
6
+ ctrlrun/errors.py,sha256=z3K6zYZgnfVU7dKNZPN3wvltbFxvJe2gZwhI193Crpk,4111
7
+ ctrlrun/policy.py,sha256=MRLSlcrzaF7TyvL_8G3P1GqMvLrc3U8_Z4pm8cnbufc,15525
8
+ ctrlrun/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ ctrlrun/receipt.py,sha256=Rg2SdXBkz_06REOsVFrrnKLifKcdJ0piJzA3Disp06o,8133
10
+ ctrlrun/state.py,sha256=zP3cIAs1U1Ubm9Vtuoeap3PrYbOwtn92op9hkYAo-YQ,45232
11
+ ctrlrun/cli/__init__.py,sha256=Z3d91Or1lFO1PUqT_AzABHfTtrutxT_3baMo5iAoREw,64
12
+ ctrlrun/cli/demo.py,sha256=JPHKdBoJ_lY8RxjTzYow1CTDfEX4Zj7fpPraSit2Zek,12121
13
+ ctrlrun/cli/main.py,sha256=DmPOJj5zWWoRaT18NYdH05Cv6aZrUKI2B9mXf961eas,8884
14
+ ctrlrun-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
15
+ ctrlrun-0.1.0.dist-info/METADATA,sha256=_OAis7Vm6kJIgAs0q15Nzqgi08J7_MFeoC_Sbfy8eGY,7147
16
+ ctrlrun-0.1.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
17
+ ctrlrun-0.1.0.dist-info/entry_points.txt,sha256=9VXdTvyK5kmTJrzhIqfmG_T-QIjoRn7Flfyjm47YLJk,50
18
+ ctrlrun-0.1.0.dist-info/top_level.txt,sha256=NFTl8mP2P7PYv0RcHY8HcApPE1k8vQYd9EpEsy0FrMo,8
19
+ ctrlrun-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ctrlrun = ctrlrun.cli.main:main
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1 @@
1
+ ctrlrun