segurai 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.
- segurai-0.1.0/LICENSE +202 -0
- segurai-0.1.0/PKG-INFO +405 -0
- segurai-0.1.0/README.md +356 -0
- segurai-0.1.0/pyproject.toml +72 -0
- segurai-0.1.0/setup.cfg +4 -0
- segurai-0.1.0/src/segurai/__init__.py +126 -0
- segurai-0.1.0/src/segurai/_claude.py +134 -0
- segurai-0.1.0/src/segurai/_version.py +4 -0
- segurai-0.1.0/src/segurai/actions.py +142 -0
- segurai-0.1.0/src/segurai/authority.py +301 -0
- segurai-0.1.0/src/segurai/cli.py +501 -0
- segurai-0.1.0/src/segurai/collector/__init__.py +0 -0
- segurai-0.1.0/src/segurai/collector/chain.py +202 -0
- segurai-0.1.0/src/segurai/collector/otlp.py +413 -0
- segurai-0.1.0/src/segurai/collector/server.py +239 -0
- segurai-0.1.0/src/segurai/collector/store.py +433 -0
- segurai-0.1.0/src/segurai/collector/web.py +282 -0
- segurai-0.1.0/src/segurai/context.py +115 -0
- segurai-0.1.0/src/segurai/instrument/__init__.py +9 -0
- segurai-0.1.0/src/segurai/instrument/langgraph.py +137 -0
- segurai-0.1.0/src/segurai/instrument/mcp.py +204 -0
- segurai-0.1.0/src/segurai/instrument/otel.py +260 -0
- segurai-0.1.0/src/segurai/intent/__init__.py +39 -0
- segurai-0.1.0/src/segurai/intent/compiler.py +257 -0
- segurai-0.1.0/src/segurai/intent/contract.py +307 -0
- segurai-0.1.0/src/segurai/intent/eval.py +273 -0
- segurai-0.1.0/src/segurai/judge/__init__.py +36 -0
- segurai-0.1.0/src/segurai/judge/eval.py +205 -0
- segurai-0.1.0/src/segurai/judge/judge.py +306 -0
- segurai-0.1.0/src/segurai/models.py +804 -0
- segurai-0.1.0/src/segurai/py.typed +0 -0
- segurai-0.1.0/src/segurai/report.py +508 -0
- segurai-0.1.0/src/segurai/runtime.py +517 -0
- segurai-0.1.0/src/segurai/scenarios.py +253 -0
- segurai-0.1.0/src/segurai.egg-info/PKG-INFO +405 -0
- segurai-0.1.0/src/segurai.egg-info/SOURCES.txt +65 -0
- segurai-0.1.0/src/segurai.egg-info/dependency_links.txt +1 -0
- segurai-0.1.0/src/segurai.egg-info/entry_points.txt +2 -0
- segurai-0.1.0/src/segurai.egg-info/requires.txt +29 -0
- segurai-0.1.0/src/segurai.egg-info/top_level.txt +1 -0
- segurai-0.1.0/tests/test_authority.py +167 -0
- segurai-0.1.0/tests/test_chain.py +111 -0
- segurai-0.1.0/tests/test_checks.py +189 -0
- segurai-0.1.0/tests/test_collector.py +211 -0
- segurai-0.1.0/tests/test_deploy.py +82 -0
- segurai-0.1.0/tests/test_examples.py +27 -0
- segurai-0.1.0/tests/test_inheritance.py +85 -0
- segurai-0.1.0/tests/test_intent.py +161 -0
- segurai-0.1.0/tests/test_intent_checks.py +126 -0
- segurai-0.1.0/tests/test_intent_claude.py +185 -0
- segurai-0.1.0/tests/test_intent_eval.py +124 -0
- segurai-0.1.0/tests/test_judge.py +207 -0
- segurai-0.1.0/tests/test_judge_eval.py +93 -0
- segurai-0.1.0/tests/test_keys.py +130 -0
- segurai-0.1.0/tests/test_langgraph.py +186 -0
- segurai-0.1.0/tests/test_mcp.py +167 -0
- segurai-0.1.0/tests/test_observed.py +170 -0
- segurai-0.1.0/tests/test_otel.py +140 -0
- segurai-0.1.0/tests/test_patterns.py +90 -0
- segurai-0.1.0/tests/test_render.py +71 -0
- segurai-0.1.0/tests/test_report.py +187 -0
- segurai-0.1.0/tests/test_runtime.py +155 -0
- segurai-0.1.0/tests/test_scope.py +128 -0
- segurai-0.1.0/tests/test_store.py +68 -0
- segurai-0.1.0/tests/test_tier1_scenarios.py +47 -0
- segurai-0.1.0/tests/test_tools_async.py +229 -0
- segurai-0.1.0/tests/test_web.py +161 -0
segurai-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
https://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
|
+
https://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.
|
segurai-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: segurai
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Provenance and authority for AI agent chains - who authorized what your agents did
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://github.com/Yaxomiller/segurai
|
|
7
|
+
Project-URL: Repository, https://github.com/Yaxomiller/segurai
|
|
8
|
+
Project-URL: Changelog, https://github.com/Yaxomiller/segurai/blob/master/CHANGELOG.md
|
|
9
|
+
Project-URL: Documentation, https://github.com/Yaxomiller/segurai/blob/master/docs/ARCHITECTURE.md
|
|
10
|
+
Project-URL: Issues, https://github.com/Yaxomiller/segurai/issues
|
|
11
|
+
Keywords: ai-agents,authorization,provenance,audit,opentelemetry,langgraph,mcp
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
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: Topic :: Security
|
|
22
|
+
Classifier: Topic :: System :: Monitoring
|
|
23
|
+
Classifier: Typing :: Typed
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: cryptography>=42.0
|
|
28
|
+
Provides-Extra: otel
|
|
29
|
+
Requires-Dist: opentelemetry-api>=1.30; extra == "otel"
|
|
30
|
+
Requires-Dist: opentelemetry-sdk>=1.30; extra == "otel"
|
|
31
|
+
Provides-Extra: langgraph
|
|
32
|
+
Requires-Dist: langgraph>=1.0; extra == "langgraph"
|
|
33
|
+
Provides-Extra: mcp
|
|
34
|
+
Requires-Dist: mcp>=2.0; extra == "mcp"
|
|
35
|
+
Provides-Extra: collector
|
|
36
|
+
Requires-Dist: opentelemetry-proto>=1.30; extra == "collector"
|
|
37
|
+
Provides-Extra: intent
|
|
38
|
+
Requires-Dist: anthropic>=1.5; extra == "intent"
|
|
39
|
+
Provides-Extra: judge
|
|
40
|
+
Requires-Dist: anthropic>=1.5; extra == "judge"
|
|
41
|
+
Provides-Extra: all
|
|
42
|
+
Requires-Dist: segurai[collector,intent,judge,langgraph,mcp,otel]; extra == "all"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
45
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
46
|
+
Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.30; extra == "dev"
|
|
47
|
+
Requires-Dist: segurai[all]; extra == "dev"
|
|
48
|
+
Dynamic: license-file
|
|
49
|
+
|
|
50
|
+
# Segurai
|
|
51
|
+
|
|
52
|
+
[](https://github.com/Yaxomiller/segurai/actions/workflows/ci.yml)
|
|
53
|
+
[](https://www.python.org/downloads/)
|
|
54
|
+
[](LICENSE)
|
|
55
|
+
|
|
56
|
+
**Provenance and authority for AI agent chains.** Records what a human asked for, records what the agents actually did, and links the two — so "who authorized this?" has an answer.
|
|
57
|
+
|
|
58
|
+
> A manager types *"clean up our old sales records."* An assistant passes the job to a CRM agent, which deletes 400 customer records. A month later an auditor asks who authorized it. Every log says: *the service account did it.*
|
|
59
|
+
>
|
|
60
|
+
> The trail from the action back to the human is broken. That is what this fixes.
|
|
61
|
+
|
|
62
|
+
Install it and import it as `segurai`. The signed grant that each agent hop carries is called a **warrant** — a narrow, written-down, traceable permission, like a search warrant — and that word is used throughout the code and the docs.
|
|
63
|
+
|
|
64
|
+
New here? [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) explains how everything fits together in plain language.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Status
|
|
69
|
+
|
|
70
|
+
**M0 — chain capture: complete.**
|
|
71
|
+
|
|
72
|
+
- Signed, attenuation-only delegation (Ed25519), with keys that persist so old chains can be re-verified
|
|
73
|
+
- Tier 1 admission checks on every action, in about a microsecond
|
|
74
|
+
- Observe mode (record and flag) and enforce mode (stop before it happens)
|
|
75
|
+
- Integrations: **LangGraph** (nodes, subgraphs, ToolNode), **MCP** (client and server), **OpenTelemetry** (GenAI semantic conventions)
|
|
76
|
+
- SQLite storage, chain reconstruction, CLI
|
|
77
|
+
- A collector that receives spans from many processes and re-checks every signature
|
|
78
|
+
|
|
79
|
+
**M1 — intent compiler: built, first live eval pending.**
|
|
80
|
+
|
|
81
|
+
- One Claude call turns a request into a scope contract (structured output, cached instructions, refusal fallbacks)
|
|
82
|
+
- Contracts are checked against the organisation's catalog and clamped to the person's real permissions
|
|
83
|
+
- Conditions that the catalog's evidence can test are written as Checks automatically
|
|
84
|
+
- A read-only web view: the request and contract beside the chain, findings inline, signatures re-verified on every load
|
|
85
|
+
- 50 labeled eval cases and a grading harness; running them needs an Anthropic API key
|
|
86
|
+
|
|
87
|
+
**M2 — Tier 1 check suite: complete.**
|
|
88
|
+
|
|
89
|
+
- Every rule an action breaks is reported: operation, target, per-action scale, session total, irreversibility, and conditions
|
|
90
|
+
- Conditions become testable Checks (e.g. `days_since_activity >= 180`), evaluated against evidence the agent reports; missing evidence is "unverifiable", never a false alarm
|
|
91
|
+
- 20 seeded scenarios: 10/10 violations caught for the right reason, 0/10 false positives, 0.15 ms per checked action (p99)
|
|
92
|
+
|
|
93
|
+
**M3 — public release: in progress.**
|
|
94
|
+
|
|
95
|
+
- Zero-integration path: existing OpenTelemetry GenAI spans become an observed chain with no code changes
|
|
96
|
+
- CI on Linux, Windows and macOS across Python 3.10–3.13, plus packaging checks
|
|
97
|
+
- Public repository, CI green on Linux, macOS and Windows across Python 3.10–3.13
|
|
98
|
+
- PyPI release wired up and waiting on one PyPI setting ([docs/RELEASING.md](docs/RELEASING.md)); distribution is the remaining work
|
|
99
|
+
|
|
100
|
+
**M4 — Tier 2 semantic judge: built, first live eval pending.**
|
|
101
|
+
|
|
102
|
+
- Reviews only the actions Tier 1 flagged, one narrow question each: within intent, outside intent, or needs a human
|
|
103
|
+
- Verdicts sit beside Tier 1's record — advice, never authority — and agent-written text is treated as untrusted data
|
|
104
|
+
- 50 labeled cases (27 ambiguous, 3 with planted prompt injection); approving a bad action counts as a dangerous miss
|
|
105
|
+
|
|
106
|
+
**M6 — scope-creep report: built.**
|
|
107
|
+
|
|
108
|
+
- Per agent and per person, over any window: operations never used, targets never touched, wildcards that could shrink, size limits against the largest real change
|
|
109
|
+
- A proposed tightened scope built only from observed use, with the evidence behind it
|
|
110
|
+
- Grants from warrants or from an identity-provider export; Markdown, HTML, JSON, and a CSV of every unused permission
|
|
111
|
+
|
|
112
|
+
**M5 — design-partner pilots: kit ready.**
|
|
113
|
+
|
|
114
|
+
- A hardened container for the collector and web view, and a Compose file that won't start without a token
|
|
115
|
+
- A pilot runbook: day-0 setup, the weekly review, the day-30 wrap-up, data handling ([docs/PILOT_RUNBOOK.md](docs/PILOT_RUNBOOK.md))
|
|
116
|
+
- The pilots themselves need partners — that part is people, not code
|
|
117
|
+
|
|
118
|
+
## Install
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pip install segurai # core: needs only `cryptography`
|
|
122
|
+
pip install "segurai[langgraph]" # + LangGraph integration
|
|
123
|
+
pip install "segurai[mcp]" # + MCP integration
|
|
124
|
+
pip install "segurai[otel]" # + OpenTelemetry spans
|
|
125
|
+
pip install "segurai[intent]" # + intent compiler (Anthropic SDK)
|
|
126
|
+
pip install "segurai[judge]" # + Tier 2 judge (Anthropic SDK)
|
|
127
|
+
pip install "segurai[collector]" # + collector protobuf support
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Working on Segurai itself:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
git clone https://github.com/Yaxomiller/segurai && cd segurai
|
|
134
|
+
pip install -e ".[dev]" # everything, plus pytest and ruff
|
|
135
|
+
python -m pytest -q
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Quick start
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import segurai
|
|
142
|
+
from segurai import Scope
|
|
143
|
+
|
|
144
|
+
segurai.configure(store="segurai.db") # signing key kept beside it as segurai.key
|
|
145
|
+
|
|
146
|
+
granted = Scope.of(
|
|
147
|
+
operations=["read", "update", "delete"],
|
|
148
|
+
targets=["crm.*"],
|
|
149
|
+
max_scale=50,
|
|
150
|
+
constraints=["only records with no recent activity"],
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
# An agent says only what it narrows; everything else is inherited.
|
|
154
|
+
@segurai.agent("crm_agent", scope=Scope.of(targets=["crm.opportunities"]))
|
|
155
|
+
def crm_agent():
|
|
156
|
+
segurai.act("read", "crm.opportunities", scale=412)
|
|
157
|
+
segurai.act("delete", "crm.opportunities", scale=400, irreversible=True)
|
|
158
|
+
|
|
159
|
+
@segurai.agent("assistant")
|
|
160
|
+
def assistant():
|
|
161
|
+
crm_agent()
|
|
162
|
+
|
|
163
|
+
with segurai.session(
|
|
164
|
+
principal="sarah@company.com",
|
|
165
|
+
request="clean up our old sales records",
|
|
166
|
+
scope=granted,
|
|
167
|
+
) as s:
|
|
168
|
+
assistant()
|
|
169
|
+
|
|
170
|
+
print(segurai.render(s.session_id))
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
Delegation chain
|
|
175
|
+
└─ entrypoint [wrt_7a07522323244bb1]
|
|
176
|
+
ops={delete,read,update} targets={crm.*} max_scale=50
|
|
177
|
+
└─ assistant [wrt_3f22fd11d57f4d91]
|
|
178
|
+
ops={delete,read,update} targets={crm.*} max_scale=50
|
|
179
|
+
└─ crm_agent [wrt_ba50b4faee524582]
|
|
180
|
+
ops={delete,read,update} targets={crm.opportunities} max_scale=50
|
|
181
|
+
[ok ] read crm.opportunities scale=412
|
|
182
|
+
[FAIL ] delete crm.opportunities scale=400
|
|
183
|
+
-> scale 400 exceeds limit 50
|
|
184
|
+
-> irreversible action not permitted by scope
|
|
185
|
+
|
|
186
|
+
Summary: 3 warrants, 2 actions, 1 violation(s)
|
|
187
|
+
! crm_agent: delete crm.opportunities (scale=400) - scale 400 exceeds limit 50; irreversible action not permitted by scope [went ahead]
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
`[FAIL ]` means the action was outside the warrant and went ahead (observe mode). With `segurai.configure(mode="enforce")` it is stopped before it happens and shows as `[BLOCKED]`.
|
|
191
|
+
|
|
192
|
+
## Guarding tools
|
|
193
|
+
|
|
194
|
+
Describe a tool once with an `ActionSpec` — what operation it performs, on which resource, at what scale — and every call is checked *before* the tool body runs:
|
|
195
|
+
|
|
196
|
+
```python
|
|
197
|
+
from segurai import ActionSpec, count
|
|
198
|
+
|
|
199
|
+
@segurai.tool(ActionSpec("delete", "crm.{table}", scale=count("ids"), irreversible=True))
|
|
200
|
+
def delete_records(table: str, ids: list[int]) -> int:
|
|
201
|
+
...
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Conditions
|
|
205
|
+
|
|
206
|
+
A plain-English condition can't be checked by a program; a `Check` can. The agent reports evidence about the records it touches, and every item must satisfy the condition:
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from segurai import Check
|
|
210
|
+
|
|
211
|
+
granted = Scope.of(
|
|
212
|
+
operations=["read", "archive"], targets=["crm.*"], max_scale=50, max_total=50,
|
|
213
|
+
checks=[Check(field="days_since_activity", op=">=", value=180,
|
|
214
|
+
condition="only records with no recent activity")],
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
segurai.act("archive", "crm.opportunities", scale=3, days_since_activity=[200, 12, 400])
|
|
218
|
+
# -> condition not met: only records with no recent activity (days_since_activity = 12, required >= 180)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
`max_total` caps the records changed across the whole session, so 400 one-record deletions can't slip under a per-action limit of 50. An action that reports no evidence for a check is marked unverifiable (`?` in the tree) rather than treated as a violation. Run the 20-scenario suite with `segurai eval-tier1`.
|
|
222
|
+
|
|
223
|
+
## LangGraph
|
|
224
|
+
|
|
225
|
+
```python
|
|
226
|
+
from segurai.instrument.langgraph import ToolGuard, agent_node
|
|
227
|
+
|
|
228
|
+
guard = ToolGuard({
|
|
229
|
+
"delete_records": ActionSpec("delete", "crm.{table}", scale=count("ids"), irreversible=True),
|
|
230
|
+
})
|
|
231
|
+
|
|
232
|
+
crm = StateGraph(MessagesState)
|
|
233
|
+
crm.add_node("model", call_model)
|
|
234
|
+
crm.add_node("tools", ToolNode(tools, wrap_tool_call=guard.wrap, awrap_tool_call=guard.awrap))
|
|
235
|
+
...
|
|
236
|
+
|
|
237
|
+
app = StateGraph(MessagesState)
|
|
238
|
+
app.add_node("crm_agent", agent_node("crm_agent", crm.compile(),
|
|
239
|
+
scope=Scope.of(targets=["crm.opportunities"])))
|
|
240
|
+
|
|
241
|
+
with segurai.session(principal="sarah@company.com", request=request, scope=granted):
|
|
242
|
+
app.invoke({"messages": [HumanMessage(request)]})
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Works for plain, async and parallel nodes, and for compiled subgraphs. In enforce mode a blocked tool call comes back to the model as an error message saying why, so the agent can change course instead of the graph crashing. Full example: [examples/langgraph_demo.py](examples/langgraph_demo.py).
|
|
246
|
+
|
|
247
|
+
## MCP
|
|
248
|
+
|
|
249
|
+
```python
|
|
250
|
+
from segurai.instrument.mcp import WarrantedClient, bind_from_meta
|
|
251
|
+
|
|
252
|
+
# Agent side: calls are checked before they are sent, and carry the warrant.
|
|
253
|
+
crm = WarrantedClient(mcp_client, server="crm", rules={...})
|
|
254
|
+
await crm.call_tool("delete_records", {"table": "opportunities", "ids": ids})
|
|
255
|
+
|
|
256
|
+
# Server side: verify the incoming warrant and continue the same chain.
|
|
257
|
+
@server.tool()
|
|
258
|
+
async def delete_records(table: str, ids: list[int], ctx: Context) -> str:
|
|
259
|
+
with bind_from_meta(ctx, holder="crm_server"):
|
|
260
|
+
segurai.act("delete", f"crm.{table}", scale=len(ids), irreversible=True)
|
|
261
|
+
...
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Tools without a rule are described from the server's own `readOnlyHint` / `destructiveHint` annotations. Full example: [examples/mcp_demo.py](examples/mcp_demo.py).
|
|
265
|
+
|
|
266
|
+
## OpenTelemetry
|
|
267
|
+
|
|
268
|
+
```python
|
|
269
|
+
from segurai.instrument import otel
|
|
270
|
+
otel.enable()
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Sessions, agent hops and tool calls become spans named per the OpenTelemetry GenAI conventions (`invoke_workflow`, `invoke_agent`, `execute_tool`), carrying the full signed warrant as `warrant.*` attributes. The chain shows up in whatever tracing backend a team already uses. Full example: [examples/otel_demo.py](examples/otel_demo.py).
|
|
274
|
+
|
|
275
|
+
## Scopes from requests
|
|
276
|
+
|
|
277
|
+
Instead of writing the scope by hand, let the intent compiler read the request. One Claude call produces a structured contract, which is checked against your catalog of real operations and resources and clamped to the person's actual permissions — so a request can never grant more than the person already has.
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
from segurai.intent import Catalog, IntentCompiler
|
|
281
|
+
|
|
282
|
+
segurai.configure(store="segurai.db", intent=IntentCompiler(Catalog.load("catalog.json")))
|
|
283
|
+
|
|
284
|
+
with segurai.session(principal="sarah@company.com",
|
|
285
|
+
request="clean up our old sales records",
|
|
286
|
+
ceiling=sarahs_permissions) as s:
|
|
287
|
+
...
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Needs `pip install -e ".[intent]"` and `ANTHROPIC_API_KEY`. Try one request with `segurai intent "clean up our old sales records" --catalog evals/intent/catalog.json`; measure the compiler on 50 labeled cases with `segurai eval-intent` (see [evals/intent/](evals/intent/README.md)).
|
|
291
|
+
|
|
292
|
+
## Collector
|
|
293
|
+
|
|
294
|
+
Agents on many machines send spans to one place with the standard OpenTelemetry OTLP exporter:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
segurai collect --db central.db --key org.pub --port 4318
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
The collector rebuilds every chain and re-checks every signature with the organisation's public key, refusing anything forged.
|
|
301
|
+
|
|
302
|
+
**Already using OpenTelemetry? Try it with no code changes.** Point your existing exporter at the collector. Standard GenAI spans (`invoke_agent`, `execute_tool`) from any framework are rebuilt into an *observed* chain: which agent called which tool, and for whom. Observed chains are clearly labeled — nothing in them was authorized, signed or checked — so they show where warrants would go before you adopt them.
|
|
303
|
+
|
|
304
|
+
## Scope-creep report
|
|
305
|
+
|
|
306
|
+
Which permissions did we give agents that they never used?
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
segurai report --days 30 # Markdown to the terminal
|
|
310
|
+
segurai report --days 30 --format csv --out unused.csv # one row per unused permission
|
|
311
|
+
segurai report --grants okta-export.json --format html --out report.html
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
For every agent, and for each person's sessions as a whole, it lists operations never used, targets never touched, wildcards that were only used for a few resources, and size limits against the largest change actually made. It then proposes a tightened scope built only from observed use (it never adds anything), with the evidence behind it. Pass `--grants` with standing permissions exported from an identity provider ([format](examples/grants.example.json)) to compare those too, including against observed chains from plain OpenTelemetry. Rarely-run work may need permissions a short window doesn't show, so every report says so and rates its confidence by how much activity it saw.
|
|
315
|
+
|
|
316
|
+
## Semantic judge (Tier 2)
|
|
317
|
+
|
|
318
|
+
Tier 1 is exact but can only compare. For the actions it flags, the judge asks Claude one narrow question: given what this person asked for, is this action within intent, outside it, or does a person need to decide?
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
segurai judge <session_id> --yes # judge the session's flagged actions
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
Verdicts are stored beside Tier 1's findings and shown in `segurai show` and the web view; they never change Tier 1's record. Everything the judge reads from agents and tools is treated as untrusted data, so "this was pre-approved" written by an agent grants nothing. Measure it with `segurai eval-judge` on 50 labeled cases (see [evals/tier2/](evals/tier2/README.md)).
|
|
325
|
+
|
|
326
|
+
## Web view
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
segurai ui --db segurai.db # then open http://127.0.0.1:8700/
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
One page per session: the request and its contract beside the delegation chain, every action's findings inline, and the signatures re-checked each time the page loads. It is plain HTML with no scripts; everything from a request is escaped, and pages carry a strict Content-Security-Policy. With `SEGURAI_COLLECTOR_TOKEN` set, the browser asks for the token as a password. The collector serves the same pages at `/`.
|
|
333
|
+
|
|
334
|
+
## Deploying a pilot
|
|
335
|
+
|
|
336
|
+
```bash
|
|
337
|
+
export SEGURAI_COLLECTOR_TOKEN="$(python -c 'import secrets; print(secrets.token_urlsafe(32))')"
|
|
338
|
+
docker compose -f deploy/compose.yaml up -d --build
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
The container runs as an unprivileged user on a read-only filesystem, keeps everything in one volume, listens only on localhost (put your TLS proxy in front), and refuses traffic from other machines without a token. Settings come from `SEGURAI_DB`, `SEGURAI_KEY`, `SEGURAI_HOST`, `SEGURAI_PORT` and `SEGURAI_COLLECTOR_TOKEN`. The [pilot runbook](docs/PILOT_RUNBOOK.md) covers the rest: keys, connecting agents, the weekly review and the final report.
|
|
342
|
+
|
|
343
|
+
## CLI
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
segurai sessions # list recent sessions
|
|
347
|
+
segurai show <session_id> # render the delegation tree (--json, --ascii)
|
|
348
|
+
segurai verify <session_id> # re-check every signature, link and narrowing
|
|
349
|
+
segurai creep <session_id> # granted vs exercised scope
|
|
350
|
+
segurai report --days 30 # scope-creep report across sessions
|
|
351
|
+
segurai keygen # create a signing key
|
|
352
|
+
segurai collect # receive spans from agents (OTLP/HTTP)
|
|
353
|
+
segurai ui # browse sessions in a web page
|
|
354
|
+
segurai backup --out copy.db # consistent copy of the database, safe while running
|
|
355
|
+
segurai intent "<request>" # compile a request into a scope contract
|
|
356
|
+
segurai eval-intent ... # grade the intent compiler on labeled cases
|
|
357
|
+
segurai eval-tier1 # run the Tier 1 scenario suite (no API calls)
|
|
358
|
+
segurai judge <session_id> # Tier 2: judge a session's flagged actions
|
|
359
|
+
segurai eval-judge # grade the judge on labeled cases
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
`--db` picks the database (default `segurai.db`); the key is found beside it.
|
|
363
|
+
|
|
364
|
+
## Design
|
|
365
|
+
|
|
366
|
+
**Warrants attenuate, never widen.** Each hop derives a child warrant from its parent. A child may narrow operations, targets, scale, or reversibility — never broaden them. Attempting to widen raises rather than silently clamping, because a caller trying to widen has a bug worth seeing. The signature covers the parent link and depth, so a chain cannot be re-parented or reordered after the fact.
|
|
367
|
+
|
|
368
|
+
If that invariant held at every hop, then whatever happened at the leaf was inside what the root principal granted. That is the whole claim.
|
|
369
|
+
|
|
370
|
+
**Patterns are compared as patterns.** A child asking for `crm.*` under a parent limited to `crm.?` must be refused, even though plain glob matching would read the child's `*` as an ordinary character and say yes. Containment is checked token by token and errs toward refusing: it may reject a scope that was technically safe, but never accepts one that isn't. Matching is case-sensitive on every platform.
|
|
371
|
+
|
|
372
|
+
**Unspecified fields inherit.** A declared child scope says what it *narrows*; anything it doesn't mention comes from the parent. Without this, narrowing one field would mean retyping every other — which trains people to paste a wide scope everywhere just to silence the error, producing exactly the over-permissioning this is meant to expose. Leaving a field out (`targets=None`) inherits it; an explicit empty list (`targets=[]`) means *none*.
|
|
373
|
+
|
|
374
|
+
**Scale bounds mutations, not reads.** An agent scanning 412 rows to find deletion candidates is doing its job; deleting 400 of them is the concern. Conflating them makes every table scan a violation and teaches people to ignore alerts.
|
|
375
|
+
|
|
376
|
+
**Unverifiable is not a violation.** When an action doesn't report the evidence a condition needs, the finding says so plainly. Treating it as a violation would bury real alerts in noise; treating it as a pass would be untrue.
|
|
377
|
+
|
|
378
|
+
**An action nobody can describe is not one anybody authorized.** A tool call whose arguments don't fit its `ActionSpec`, or a tool nobody wrote a spec for, is recorded as a violation rather than waved through.
|
|
379
|
+
|
|
380
|
+
**Observe by default.** Violations are recorded, nothing is blocked. Nobody lets an unproven library block production traffic — but they will let it watch, and watching produces the evidence that earns the right to enforce later.
|
|
381
|
+
|
|
382
|
+
**Observability never breaks the agent.** A failing listener or exporter is logged and ignored.
|
|
383
|
+
|
|
384
|
+
## What's next
|
|
385
|
+
|
|
386
|
+
| Milestone | |
|
|
387
|
+
|---|---|
|
|
388
|
+
| M1 | Intent compiler — built; first live eval run pending |
|
|
389
|
+
| M2 | Tier 1 check suite — complete: 10/10 caught, 0 false positives |
|
|
390
|
+
| M3 | Public release; ingest existing OpenTelemetry spans with no code changes |
|
|
391
|
+
| M4 | Tier 2 semantic judge — built; first live eval pending |
|
|
392
|
+
| M5 | Design-partner pilots — deployment kit and runbook ready |
|
|
393
|
+
| M6 | Scope-creep report — built |
|
|
394
|
+
|
|
395
|
+
Known limits are listed honestly at the end of [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md#honest-limits-what-is-not-done-yet).
|
|
396
|
+
|
|
397
|
+
## Tests
|
|
398
|
+
|
|
399
|
+
```bash
|
|
400
|
+
python -m pytest -q
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
## License
|
|
404
|
+
|
|
405
|
+
Apache-2.0
|