ctrlrun 0.1.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.
- ctrlrun-0.1.0/CHANGELOG.md +73 -0
- ctrlrun-0.1.0/LICENSE +202 -0
- ctrlrun-0.1.0/MANIFEST.in +22 -0
- ctrlrun-0.1.0/PKG-INFO +164 -0
- ctrlrun-0.1.0/README.md +137 -0
- ctrlrun-0.1.0/SECURITY.md +38 -0
- ctrlrun-0.1.0/VISION.md +121 -0
- ctrlrun-0.1.0/ctrlrun.example.yaml +34 -0
- ctrlrun-0.1.0/docs/ARCHITECTURE.md +152 -0
- ctrlrun-0.1.0/docs/CLAIMS.md +60 -0
- ctrlrun-0.1.0/docs/ROADMAP.md +86 -0
- ctrlrun-0.1.0/docs/SPEC-v0.1.md +560 -0
- ctrlrun-0.1.0/docs/THREAT_MODEL.md +75 -0
- ctrlrun-0.1.0/pyproject.toml +80 -0
- ctrlrun-0.1.0/setup.cfg +4 -0
- ctrlrun-0.1.0/src/ctrlrun/__init__.py +67 -0
- ctrlrun-0.1.0/src/ctrlrun/action.py +161 -0
- ctrlrun-0.1.0/src/ctrlrun/approval.py +447 -0
- ctrlrun-0.1.0/src/ctrlrun/cli/__init__.py +1 -0
- ctrlrun-0.1.0/src/ctrlrun/cli/demo.py +300 -0
- ctrlrun-0.1.0/src/ctrlrun/cli/main.py +260 -0
- ctrlrun-0.1.0/src/ctrlrun/control.py +822 -0
- ctrlrun-0.1.0/src/ctrlrun/effect.py +296 -0
- ctrlrun-0.1.0/src/ctrlrun/errors.py +114 -0
- ctrlrun-0.1.0/src/ctrlrun/policy.py +389 -0
- ctrlrun-0.1.0/src/ctrlrun/py.typed +0 -0
- ctrlrun-0.1.0/src/ctrlrun/receipt.py +229 -0
- ctrlrun-0.1.0/src/ctrlrun/state.py +1131 -0
- ctrlrun-0.1.0/src/ctrlrun.egg-info/PKG-INFO +164 -0
- ctrlrun-0.1.0/src/ctrlrun.egg-info/SOURCES.txt +40 -0
- ctrlrun-0.1.0/src/ctrlrun.egg-info/dependency_links.txt +1 -0
- ctrlrun-0.1.0/src/ctrlrun.egg-info/entry_points.txt +2 -0
- ctrlrun-0.1.0/src/ctrlrun.egg-info/requires.txt +7 -0
- ctrlrun-0.1.0/src/ctrlrun.egg-info/top_level.txt +1 -0
- ctrlrun-0.1.0/tests/conftest.py +42 -0
- ctrlrun-0.1.0/tests/test_action.py +389 -0
- ctrlrun-0.1.0/tests/test_approval.py +903 -0
- ctrlrun-0.1.0/tests/test_concurrency.py +547 -0
- ctrlrun-0.1.0/tests/test_demo.py +975 -0
- ctrlrun-0.1.0/tests/test_effect.py +1562 -0
- ctrlrun-0.1.0/tests/test_policy.py +738 -0
- ctrlrun-0.1.0/tests/test_protect.py +743 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project follows
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
Public API names are frozen in `docs/SPEC-v0.1.md` §8. Before 1.0 they may still change, and
|
|
8
|
+
any change to one appears here.
|
|
9
|
+
|
|
10
|
+
## [Unreleased]
|
|
11
|
+
|
|
12
|
+
## [0.1.0] — 2026-09-03
|
|
13
|
+
|
|
14
|
+
First packaged release. The v0.1 kernel is complete: every acceptance test in
|
|
15
|
+
`docs/SPEC-v0.1.md` §7 passes, including the multi-process concurrency test.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- **Action** — canonical form, `action_hash`, deep-frozen arguments. `float` is rejected in
|
|
20
|
+
arguments: `0.1` and `0.10` are the same money and different hashes.
|
|
21
|
+
- **Policy** — YAML loader with `ALLOW` / `APPROVE` / `DENY` and fail-closed defaults. An
|
|
22
|
+
unknown action is denied; there is no default-allow. See the config-breaking rule below
|
|
23
|
+
for how condition keys are validated.
|
|
24
|
+
- **`@ctrlrun.protect()`** — binds a function call to an Action, evaluates it, and executes
|
|
25
|
+
from the action's canonical arguments rather than the caller's objects.
|
|
26
|
+
- **Approval binding** — approvals carry the `action_hash` of what a human saw, and are
|
|
27
|
+
single-use and expiring. A mutated action cannot present an approval granted for another.
|
|
28
|
+
- **Effect key and reservation** — template-resolved effect identity, reserved atomically
|
|
29
|
+
across processes via `BEGIN IMMEDIATE` and a unique constraint on `effect_key`.
|
|
30
|
+
- **Effect state machine** — `NEW → RESERVED → EXECUTING → COMMITTED | FAILED | AMBIGUOUS`.
|
|
31
|
+
Only an executor raising `NotExecuted` produces `FAILED`; every other exception, timeouts
|
|
32
|
+
included, produces `AMBIGUOUS`, and only a human resolves it.
|
|
33
|
+
- **Receipts and events** — portable JSONL evidence for every action.
|
|
34
|
+
- **CLI** — `init`, `demo`, `approve`, `deny`, `receipts`, `effects`, `resolve`.
|
|
35
|
+
- **`ctrlrun demo`** — four failure scenarios, in process, no network.
|
|
36
|
+
- `SECURITY.md` and `docs/CLAIMS.md`, which maps every README claim to its code and test.
|
|
37
|
+
|
|
38
|
+
### Config-breaking rules
|
|
39
|
+
|
|
40
|
+
Rules that reject a policy file which an earlier build of this kernel would have loaded.
|
|
41
|
+
A `ctrlrun.yaml` written before this release may need an edit; the process refuses to start
|
|
42
|
+
until it gets one, which is the point.
|
|
43
|
+
|
|
44
|
+
- **A condition key naming an `Action` field is now a load-time `PolicyError`.** The
|
|
45
|
+
reserved names are `action_id`, `agent`, `environment`, `principal`, `resource` and
|
|
46
|
+
`user`. `when: { environment_eq: production }` reads exactly like it scopes a rule to
|
|
47
|
+
production, and matched nothing at all — conditions address an action's *arguments*, and
|
|
48
|
+
those are not arguments. Combined with a catch-all `decision: allow` beneath it, a rule
|
|
49
|
+
that looked restrictive silently permitted everything. If a protected function genuinely
|
|
50
|
+
takes an argument by one of those names, rename the argument (SPEC-v0.1 §3.2). Only the
|
|
51
|
+
whole name is reserved: `resource_id_eq` is unaffected.
|
|
52
|
+
- **A condition on an argument the action does not carry now logs a warning.** The decision
|
|
53
|
+
is unchanged — still false, still never an error, per SPEC-v0.1 §3.2 — but a typo such as
|
|
54
|
+
`amont_lte` no longer disappears in silence. Nothing to edit; expect new log output.
|
|
55
|
+
|
|
56
|
+
### Notes
|
|
57
|
+
|
|
58
|
+
- Requires Python ≥ 3.11. Runtime dependencies are `pyyaml` and `click`.
|
|
59
|
+
- Single-host only: reservation is atomic across processes on one machine via SQLite.
|
|
60
|
+
Multi-host needs the Postgres store planned for v0.6.
|
|
61
|
+
- Receipts are not signed. A database administrator can alter history (v0.6).
|
|
62
|
+
- Approver identity is free text and is not authenticated (v0.3).
|
|
63
|
+
- Generated ids (`act_`, `apr_`, `ctr_`) are 128 bits. An approval id is not a bearer token
|
|
64
|
+
in v0.1 — consuming one needs write access to the store — but it becomes one with the
|
|
65
|
+
webhook provider in v0.2, and an id format cannot be widened after records exist.
|
|
66
|
+
- Effect key templates do not escape placeholder values, so a crafted argument can make two
|
|
67
|
+
distinct effects share one key. The result is a refusal rather than a double execution;
|
|
68
|
+
`docs/THREAT_MODEL.md` states the limit and the workaround.
|
|
69
|
+
- Policy conditions address an action's arguments only. Scoping a rule by environment,
|
|
70
|
+
resource or principal arrives with the authority model in v0.3.
|
|
71
|
+
|
|
72
|
+
[Unreleased]: https://github.com/CTRLRun/ctrlrun/compare/v0.1.0...HEAD
|
|
73
|
+
[0.1.0]: https://github.com/CTRLRun/ctrlrun/releases/tag/v0.1.0
|
ctrlrun-0.1.0/LICENSE
ADDED
|
@@ -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,22 @@
|
|
|
1
|
+
# What ships in the sdist beyond the package itself.
|
|
2
|
+
#
|
|
3
|
+
# The tests go in the sdist because a distribution packager builds from it and runs them.
|
|
4
|
+
# That only works if everything they need goes too: `tests/conftest.py` holds the fixtures
|
|
5
|
+
# every store test is parametrized over, and `ctrlrun.example.yaml` is asserted against by
|
|
6
|
+
# `test_the_shipped_example_policy_is_the_one_in_the_repository`. Shipping tests that cannot
|
|
7
|
+
# run is worse than shipping none, so `test_the_sdist_carries_everything_the_tests_need`
|
|
8
|
+
# keeps this file honest.
|
|
9
|
+
|
|
10
|
+
include ctrlrun.example.yaml
|
|
11
|
+
include CHANGELOG.md
|
|
12
|
+
include SECURITY.md
|
|
13
|
+
include VISION.md
|
|
14
|
+
recursive-include docs *.md
|
|
15
|
+
recursive-include tests *.py
|
|
16
|
+
|
|
17
|
+
# Local-only: working notes, and anything an operator's run left behind. Nothing here is
|
|
18
|
+
# picked up by default — these are belt and braces, so a stray file cannot ride along.
|
|
19
|
+
prune internal
|
|
20
|
+
prune .ctrlrun
|
|
21
|
+
prune .github
|
|
22
|
+
global-exclude *.py[cod] .DS_Store
|
ctrlrun-0.1.0/PKG-INFO
ADDED
|
@@ -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.
|
ctrlrun-0.1.0/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# CTRLRun
|
|
2
|
+
|
|
3
|
+
**Transaction safety for AI-agent actions.**
|
|
4
|
+
|
|
5
|
+
> Agents can retry. Your refund shouldn't.
|
|
6
|
+
|
|
7
|
+
CTRLRun is open-source infrastructure for controlling consequential AI-agent actions.
|
|
8
|
+
|
|
9
|
+
You decide, per action, what an agent can do autonomously, what requires human approval, and what is blocked.
|
|
10
|
+
|
|
11
|
+
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.
|
|
12
|
+
|
|
13
|
+
**Autonomy belongs to the action, not the agent.**
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## The problem
|
|
18
|
+
|
|
19
|
+
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.
|
|
20
|
+
|
|
21
|
+
The hard part is what happens at the boundary between *intention* and *effect*:
|
|
22
|
+
|
|
23
|
+
- A refund commits at Stripe, the response times out, the agent retries. **Did you just refund twice?**
|
|
24
|
+
- A human approves a €500 refund. The agent changes it to €5,000 before executing. **Should that approval still count?**
|
|
25
|
+
- Two agents pick up the same task and issue the same refund. **Which one wins?**
|
|
26
|
+
- A call timed out. Your framework marks it *failed* and retries. **It wasn't failed. It was unknown.**
|
|
27
|
+
|
|
28
|
+
CTRLRun owns that boundary.
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install ctrlrun
|
|
34
|
+
ctrlrun demo
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`ctrlrun demo` runs the four failure scenarios below in well under a second, with no external services.
|
|
38
|
+
|
|
39
|
+
Protect your first action:
|
|
40
|
+
|
|
41
|
+
```python
|
|
42
|
+
import ctrlrun
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@ctrlrun.protect("stripe.refund", effect="refund:{payment_id}")
|
|
46
|
+
def refund(payment_id: str, amount: int, currency: str = "EUR"):
|
|
47
|
+
return stripe.refunds.create(payment_intent=payment_id, amount=amount)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Configure autonomy per action in `ctrlrun.yaml`:
|
|
51
|
+
|
|
52
|
+
```yaml
|
|
53
|
+
schema: ctrlrun.policy/v1
|
|
54
|
+
|
|
55
|
+
actions:
|
|
56
|
+
customer.read:
|
|
57
|
+
decision: allow
|
|
58
|
+
|
|
59
|
+
stripe.refund:
|
|
60
|
+
rules:
|
|
61
|
+
- when: { amount_gte: 0, amount_lte: 50000 } # up to €500.00
|
|
62
|
+
decision: allow
|
|
63
|
+
- when: { amount_gte: 0, amount_lte: 500000 } # up to €5,000.00
|
|
64
|
+
decision: approve
|
|
65
|
+
- decision: deny
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
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.
|
|
69
|
+
|
|
70
|
+
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.
|
|
71
|
+
|
|
72
|
+
## What `ctrlrun demo` shows
|
|
73
|
+
|
|
74
|
+
```console
|
|
75
|
+
$ ctrlrun demo
|
|
76
|
+
CTRLRun demo — four ways an agent action goes wrong, and what stops it.
|
|
77
|
+
Policy: refunds up to €1,000 are autonomous, up to €10,000 need a human, above that are denied.
|
|
78
|
+
|
|
79
|
+
1. Duplicate effect after a lost response
|
|
80
|
+
|
|
81
|
+
refund €500 → remote commits → response lost → effect: AMBIGUOUS
|
|
82
|
+
agent retries the same refund
|
|
83
|
+
✗ BLOCKED — effect may already have committed; blind retry refused
|
|
84
|
+
remote refund calls: 1
|
|
85
|
+
only a human moves it on: ctrlrun resolve refund:txn_1 --committed|--failed
|
|
86
|
+
|
|
87
|
+
2. Approval mutation
|
|
88
|
+
|
|
89
|
+
agent proposes refund €2,000 → human approves apr_0aa78e0380ba55d77a601dc782f57095 (bound to the action hash)
|
|
90
|
+
agent executes refund €5,000 →
|
|
91
|
+
✗ BLOCKED — approved action ≠ requested action (mismatch)
|
|
92
|
+
|
|
93
|
+
3. Concurrent agents, same effect
|
|
94
|
+
|
|
95
|
+
Agent A reserve refund:txn_123 → ACQUIRED → executes
|
|
96
|
+
Agent B reserve refund:txn_123 →
|
|
97
|
+
✗ BLOCKED — already reserved (in_progress)
|
|
98
|
+
|
|
99
|
+
4. Approval replay
|
|
100
|
+
|
|
101
|
+
approval apr_dbc8bc6f06690cdf2e2c55a4e591ef3b used once → consumed
|
|
102
|
+
same approval presented again →
|
|
103
|
+
✗ BLOCKED — single-use approval already consumed
|
|
104
|
+
|
|
105
|
+
Receipts (7): .ctrlrun/demo/receipts.jsonl
|
|
106
|
+
Events: .ctrlrun/demo/events.jsonl
|
|
107
|
+
|
|
108
|
+
Read them: CTRLRUN_STATE=.ctrlrun/demo/state.db ctrlrun receipts
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Approval ids are generated per run; everything else is byte-for-byte what the demo prints.
|
|
112
|
+
|
|
113
|
+
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.
|
|
114
|
+
|
|
115
|
+
Every executed action produces a portable JSON receipt: who, what, arguments, decision, approval, effect key, and result (`committed`, `failed`, or `ambiguous`).
|
|
116
|
+
|
|
117
|
+
## What CTRLRun is not
|
|
118
|
+
|
|
119
|
+
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.
|
|
120
|
+
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
## Documentation
|
|
124
|
+
|
|
125
|
+
| Doc | Purpose |
|
|
126
|
+
|---|---|
|
|
127
|
+
| [`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 |
|
|
128
|
+
| [`docs/ARCHITECTURE.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/ARCHITECTURE.md) | Kernel design and key decisions |
|
|
129
|
+
| [`docs/ROADMAP.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/ROADMAP.md) | v0.1 → v1.0 |
|
|
130
|
+
| [`docs/THREAT_MODEL.md`](https://github.com/CTRLRun/ctrlrun/blob/main/docs/THREAT_MODEL.md) | What CTRLRun defends against and what it doesn't |
|
|
131
|
+
| [`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 |
|
|
132
|
+
| [`SECURITY.md`](https://github.com/CTRLRun/ctrlrun/blob/main/SECURITY.md) | Reporting a vulnerability |
|
|
133
|
+
| [`VISION.md`](https://github.com/CTRLRun/ctrlrun/blob/main/VISION.md) | Where this can go — not a build spec |
|
|
134
|
+
|
|
135
|
+
## License
|
|
136
|
+
|
|
137
|
+
Apache-2.0. The enforcement kernel is and will remain fully open source.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Report vulnerabilities privately to **contact@arpanghoshal.com**. Please do not open a public
|
|
6
|
+
issue for a security report.
|
|
7
|
+
|
|
8
|
+
Include what you need to make the problem reproducible: the version, the policy file, and the
|
|
9
|
+
sequence of actions. A failing test is the fastest possible report.
|
|
10
|
+
|
|
11
|
+
Expect an acknowledgement within 72 hours and an assessment within seven days. If a fix is
|
|
12
|
+
warranted you will be credited in the release notes unless you ask not to be.
|
|
13
|
+
|
|
14
|
+
## Supported versions
|
|
15
|
+
|
|
16
|
+
CTRLRun is pre-1.0. Only the latest release receives fixes.
|
|
17
|
+
|
|
18
|
+
| Version | Supported |
|
|
19
|
+
|---|---|
|
|
20
|
+
| 0.1.x | yes |
|
|
21
|
+
| < 0.1 | no |
|
|
22
|
+
|
|
23
|
+
## What counts as a vulnerability
|
|
24
|
+
|
|
25
|
+
CTRLRun sits in the execution path of consequential actions. Treat anything that breaks one of
|
|
26
|
+
these as a security issue, not a bug:
|
|
27
|
+
|
|
28
|
+
- An action executes that policy should have denied.
|
|
29
|
+
- An approval authorizes an action other than the exact one a human saw.
|
|
30
|
+
- A consumed, expired, or mismatched approval is accepted.
|
|
31
|
+
- The same logical effect is reserved twice, in any interleaving, across threads or processes.
|
|
32
|
+
- An unknown execution outcome is recorded as `failed` rather than `ambiguous`.
|
|
33
|
+
- A receipt does not reflect what happened.
|
|
34
|
+
|
|
35
|
+
`docs/THREAT_MODEL.md` states what is deliberately out of scope — a compromised host, a
|
|
36
|
+
malicious administrator with write access to the state database, a lying external service, or
|
|
37
|
+
code that bypasses the decorator entirely. Those are documented limits rather than
|
|
38
|
+
vulnerabilities, but if you think one is stated too generously, say so.
|