underwrit 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. underwrit-0.3.0/LICENSE +202 -0
  2. underwrit-0.3.0/NOTICE +4 -0
  3. underwrit-0.3.0/PKG-INFO +174 -0
  4. underwrit-0.3.0/README.md +156 -0
  5. underwrit-0.3.0/pyproject.toml +30 -0
  6. underwrit-0.3.0/setup.cfg +4 -0
  7. underwrit-0.3.0/tests/test_approval_ops.py +145 -0
  8. underwrit-0.3.0/tests/test_approvers.py +108 -0
  9. underwrit-0.3.0/tests/test_argument_hygiene.py +111 -0
  10. underwrit-0.3.0/tests/test_auth.py +258 -0
  11. underwrit-0.3.0/tests/test_authority.py +291 -0
  12. underwrit-0.3.0/tests/test_conformance.py +142 -0
  13. underwrit-0.3.0/tests/test_contract.py +200 -0
  14. underwrit-0.3.0/tests/test_engine_knobs.py +124 -0
  15. underwrit-0.3.0/tests/test_evidence_v2.py +259 -0
  16. underwrit-0.3.0/tests/test_gate.py +137 -0
  17. underwrit-0.3.0/tests/test_hardening.py +462 -0
  18. underwrit-0.3.0/tests/test_integrations.py +124 -0
  19. underwrit-0.3.0/tests/test_ops.py +285 -0
  20. underwrit-0.3.0/tests/test_orbitshield_client.py +148 -0
  21. underwrit-0.3.0/tests/test_policy_plane.py +195 -0
  22. underwrit-0.3.0/tests/test_receipts_and_clients.py +147 -0
  23. underwrit-0.3.0/tests/test_replay.py +68 -0
  24. underwrit-0.3.0/tests/test_retention.py +215 -0
  25. underwrit-0.3.0/tests/test_sdk.py +117 -0
  26. underwrit-0.3.0/tests/test_timestamps.py +169 -0
  27. underwrit-0.3.0/tests/test_tokens.py +102 -0
  28. underwrit-0.3.0/tests/test_value_sinks.py +76 -0
  29. underwrit-0.3.0/underwrit/__init__.py +19 -0
  30. underwrit-0.3.0/underwrit/__main__.py +3 -0
  31. underwrit-0.3.0/underwrit/api.py +1763 -0
  32. underwrit-0.3.0/underwrit/auth.py +348 -0
  33. underwrit-0.3.0/underwrit/backup.py +125 -0
  34. underwrit-0.3.0/underwrit/bundle.py +110 -0
  35. underwrit-0.3.0/underwrit/cedar.py +150 -0
  36. underwrit-0.3.0/underwrit/chain.py +519 -0
  37. underwrit-0.3.0/underwrit/checkpoint.py +428 -0
  38. underwrit-0.3.0/underwrit/cli.py +155 -0
  39. underwrit-0.3.0/underwrit/db.py +377 -0
  40. underwrit-0.3.0/underwrit/demo.py +310 -0
  41. underwrit-0.3.0/underwrit/ecdsa_p256.py +108 -0
  42. underwrit-0.3.0/underwrit/ed25519.py +171 -0
  43. underwrit-0.3.0/underwrit/evidence.py +590 -0
  44. underwrit-0.3.0/underwrit/mcp.py +147 -0
  45. underwrit-0.3.0/underwrit/merkle.py +144 -0
  46. underwrit-0.3.0/underwrit/migrate.py +186 -0
  47. underwrit-0.3.0/underwrit/obs.py +108 -0
  48. underwrit-0.3.0/underwrit/oidc.py +362 -0
  49. underwrit-0.3.0/underwrit/opa.py +103 -0
  50. underwrit-0.3.0/underwrit/policy.py +933 -0
  51. underwrit-0.3.0/underwrit/ratelimit.py +46 -0
  52. underwrit-0.3.0/underwrit/recorder.py +139 -0
  53. underwrit-0.3.0/underwrit/replay.py +136 -0
  54. underwrit-0.3.0/underwrit/retention.py +220 -0
  55. underwrit-0.3.0/underwrit/store.py +607 -0
  56. underwrit-0.3.0/underwrit/subject.py +57 -0
  57. underwrit-0.3.0/underwrit/taskdraft.py +40 -0
  58. underwrit-0.3.0/underwrit/tsa.py +180 -0
  59. underwrit-0.3.0/underwrit.egg-info/PKG-INFO +174 -0
  60. underwrit-0.3.0/underwrit.egg-info/SOURCES.txt +62 -0
  61. underwrit-0.3.0/underwrit.egg-info/dependency_links.txt +1 -0
  62. underwrit-0.3.0/underwrit.egg-info/entry_points.txt +2 -0
  63. underwrit-0.3.0/underwrit.egg-info/requires.txt +3 -0
  64. underwrit-0.3.0/underwrit.egg-info/top_level.txt +1 -0
@@ -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 2026 Orbitward
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.
underwrit-0.3.0/NOTICE ADDED
@@ -0,0 +1,4 @@
1
+ Underwrit
2
+ Copyright 2026 Orbitward
3
+
4
+ This product includes software developed by Orbitward (https://underwrit.dev).
@@ -0,0 +1,174 @@
1
+ Metadata-Version: 2.4
2
+ Name: underwrit
3
+ Version: 0.3.0
4
+ Summary: The Underwrit data plane: a decision plane for agent tool calls, and evidence anyone can verify offline. Apache-2.0.
5
+ License: Apache-2.0
6
+ Project-URL: Homepage, https://github.com/underwrit-io/dataplane
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Topic :: Security
10
+ Classifier: Topic :: System :: Logging
11
+ Requires-Python: >=3.11
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ License-File: NOTICE
15
+ Provides-Extra: postgres
16
+ Requires-Dist: psycopg[binary,pool]>=3.1; extra == "postgres"
17
+ Dynamic: license-file
18
+
19
+ # Underwrit
20
+
21
+ Verifiable evidence for what an agent did, and a decision plane in front of it.
22
+
23
+ Two processes, and the split is the product:
24
+
25
+ | | |
26
+ |---|---|
27
+ | **data plane** — `python3 -m underwrit serve` | Runs on your side. Decides, records every decision to a hash chain, produces evidence packs. Keeps deciding when the control plane is unreachable. |
28
+ | **control plane** — `python3 -m underwrit control` | Hosted, multi-tenant. Distributes policy, counts usage. Never receives an action's arguments. Never in the decision path. |
29
+
30
+ ```
31
+ python3 -m underwrit demo-stack # both planes, the console, seeded sessions, sign-in links
32
+ python3 -m underwrit demo --live # in a second terminal: an incident held, approved by two people, claimed, verified
33
+ ```
34
+
35
+ Or with Docker: `docker compose up -d`, then `docker compose --profile demo run --rm demo`.
36
+ [`docs/DEMO.md`](docs/DEMO.md) is the twelve-minute runbook.
37
+
38
+ Or without Docker: `python3 -m underwrit control 8788`, mint a node token, then
39
+ `UNDERWRIT_CONTROL_URL=http://127.0.0.1:8788 UNDERWRIT_NODE_TOKEN=... python3 -m underwrit serve 8787`,
40
+ `UNDERWRIT_TOKEN=... python3 -m underwrit demo`, and `cd console && npm install && npm run dev`.
41
+ [`docs/OPERATIONS.md`](docs/OPERATIONS.md) has the rest.
42
+
43
+ ## Open core
44
+
45
+ This repository is the **Underwrit data plane**, licensed under Apache-2.0: the decision engine, the
46
+ hash chain, the Merkle checkpoints, the evidence format and the verifier every bundle ships, the
47
+ Python and TypeScript clients, the MCP server, the benchmark and the research notes. It runs on
48
+ its own with a local policy and produces evidence a third party can verify without trusting you —
49
+ which is the part that has to be open for the evidence to mean anything.
50
+
51
+ **Underwrit Control Plane** is licensed commercially and adds the control plane (policy distribution,
52
+ multi-tenancy, witnessing and cosignatures), the approvals console, single sign-on operations,
53
+ Helm charts, Terraform and managed deployment. It installs beside this package
54
+ (licensed commercially, shipped as container images, never on PyPI or npm) and `underwrit control` / `underwrit demo-stack` hand off to it.
55
+
56
+ ## What it does
57
+
58
+ An agent proposes an action. The plane answers with the action, everything already in that session,
59
+ and the operator's policy — `allow`, `allow_recorded`, `require_human` or `deny` — writes the
60
+ decision to a hash chain, and hands back a bundle anybody can verify offline.
61
+
62
+ Two signals decide. **Taint**: has this session consumed content a third party could have
63
+ authored? **Authority**: are the values that carry the action — recipient, amount, host, grant
64
+ target, any embedded link — named by the user, by a trusted source, or only by that content? A
65
+ tainted hold whose every such value the user named becomes a record; a value that arrived only in
66
+ untrusted content is held even for a small action.
67
+
68
+ An approval is a contract, not a flag: bound to the exact arguments, the policy version, whatever
69
+ state the caller said must still hold, and a clock. Immediately before executing, the runtime
70
+ *claims* it, and the claim is refused if anything changed, the approval expired, or it was already
71
+ used. Verification of what happened afterwards is recorded apart from whether the call succeeded.
72
+
73
+ ```
74
+ POST /v1/sessions open a session
75
+ POST /v1/decide propose an action (idempotencyKey, preconditions optional)
76
+ POST /v1/decisions/:id/resolve a person answers a held decision
77
+ POST /v1/decisions/:id/claim revalidate an approval with the same arguments, exactly once
78
+ POST /v1/outcome what happened, what came back, and what was verified
79
+ GET /v1/evidence/:id the pack
80
+ GET /v1/evidence/:id/bundle zip, with verify.py inside
81
+ POST /v1/policy/replay the shadow report: what a candidate policy would have done
82
+ GET /v1/retention POST /v1/holds what is kept, and legal holds
83
+ GET /v1/tokens POST /v1/tokens/:id/rotate|revoke
84
+ POST /v1/policy/import Cedar → deniedTools, allowlist, ceilings (preview, then apply)
85
+ GET /v1/approvers POST /v1/holds/escalate who answers, how fast; escalate overdue holds
86
+ GET /v1/checkpoint the signed tree, its witnesses and external timestamps
87
+ ```
88
+
89
+ Clients: [`sdk/python`](sdk/python) (`pip install underwrit-client`, stdlib only — twenty lines to
90
+ integrate a runtime), [`sdk/typescript`](sdk/typescript), and `python3 -m underwrit mcp` for any
91
+ MCP-capable agent. Adapters for Claude Code (`underwrit-hook`), the OpenAI Agents SDK, LangGraph,
92
+ Google ADK, the Vercel AI SDK, gateways with an HTTP pre-call hook, and OpenTelemetry.
93
+
94
+ Measured on AgentDojo with real tool outputs, over the 501 attack pairs in which the injection
95
+ produced an action: the authority check catches 436 (87%) where taint alone caught 356, and 496
96
+ (99%) with domain sinks declared; an attacker who renames the sink to an unknown tool is still
97
+ caught 397 times where a name-based check caught 21. On tasks where the user named every value
98
+ (deploys, transfers to a named account) it interrupted none of 18 sink calls; on open tasks ("read
99
+ my inbox and reply") it still asks a person most of the time, so shadow mode stays the default
100
+ there. `docs/RESEARCH.md` has the tables, the kill criteria and their limits.
101
+
102
+ Evidence is signed (Ed25519), Merkle-proven (RFC 9162), cosigned by as many witnesses as you
103
+ configure (C2SP), and time-stamped by an RFC 3161 authority and OpenTimestamps when configured;
104
+ `verify.py` in every bundle checks all of it with the standard library. Sign-in is OpenID Connect
105
+ (RS256/ES256/EdDSA) or SPIFFE JWT-SVIDs; policy can be tightened by OPA or imported from Cedar.
106
+
107
+ ## Who may act
108
+
109
+ Four roles, and the separation is the point: an **agent** proposes, an **approver** answers (two
110
+ distinct people in production), an **auditor** reads, an **admin** sets policy and mints tokens
111
+ and cannot approve. People sign in through your identity provider (OpenID Connect; a Keycloak
112
+ realm ships in `deploy/keycloak`) or with a token minted from the data plane; runtimes use tokens
113
+ or client credentials. When the provider is down, `underwrit break-glass` mints a short-lived emergency
114
+ credential from the host, and every request it makes is recorded under the operator's name.
115
+
116
+ ## Shadow mode is the default, and that is a finding not a caution
117
+
118
+ Measured against [AgentDojo](https://github.com/ethz-spylab/agentdojo) — 123 traces authored by
119
+ people who had never seen this rule — session taint caught 16 of 26 attacks while interrupting 26 of
120
+ 97 benign sessions: **one interrupt per 2.2 legitimate sink calls**, against a target of one in
121
+ twenty. Tuning detection up to 88% took it to one in 1.2. Detection and false positives moved
122
+ together, which is what a signal that does not discriminate looks like.
123
+
124
+ So the engine decides on every action and records it, and `enforce` decides whether a caller is told
125
+ to act on the verdict. Off unless an operator turns it on, per environment, after looking at their
126
+ own traffic — which is what the console's Policy view shows them before they apply a change.
127
+
128
+ ## What the evidence proves
129
+
130
+ That no entry present has been altered or reordered, no file edited, and — format 2 — that each
131
+ entry sits at its stated position in a log of the stated size, under a checkpoint signed with the
132
+ data plane's Ed25519 key. **Not** that the record is complete — only the entries present can be
133
+ checked. And not origin from the bundle alone: pin the key from `GET /v1/keys` when you verify.
134
+ Every pack says so in its own README, and `verify.py` says it again when you run it.
135
+
136
+ Arguments expire (`UNDERWRIT_RETENTION_DAYS`, per environment); the chain holds digests and is untouched,
137
+ so a pack built after a sweep verifies exactly as one built before. A legal hold exempts a subject
138
+ and is visible in its pack.
139
+
140
+ The format is in [`spec/evidence-format.md`](spec/evidence-format.md), with test vectors. It and the
141
+ verifier are MIT: an evidence format only its vendor can read is not evidence.
142
+
143
+ ## Layout
144
+
145
+ ```
146
+ underwrit/
147
+ chain.py hash-chained log — append, verify, redact, seal
148
+ evidence.py pack builder + the offline verifier
149
+ subject.py what a pack is about; the library never queries a host table
150
+ policy.py the decision engine: taint and authority
151
+ merkle.py RFC 9162 tree and proofs
152
+ ed25519.py RFC 8032, pure Python
153
+ checkpoint.py the log key and signed checkpoints
154
+ replay.py the shadow report
155
+ store.py sessions and decisions; arguments live here, digests go in the chain
156
+ retention.py sweeps, legal holds, the policy in force
157
+ auth.py roles, tokens (expiry, rotation, tenant, break glass), quorum
158
+ oidc.py OpenID Connect verification and role mapping
159
+ api.py data plane
160
+ control.py control plane — tenants, policy, fleet, usage, quota
161
+ migrate.py versioned schema
162
+ backup.py backups that end in verify_chain()
163
+ obs.py structured logs (never an argument) and /metrics
164
+ ratelimit.py per-token token bucket
165
+ mcp.py the MCP entry point
166
+ recorder.py 139-line reference recorder over a Store protocol
167
+ bundle.py zip assembly and the signed manifest; db.py the SQLite/Postgres layer
168
+ tsa.py RFC 3161 and OpenTimestamps; ecdsa_p256.py ES256; opa.py, cedar.py the policy plane
169
+ taskdraft.py a task policy drafted from the request without a model; demo.py, demo_stack.py
170
+ sdk/ Python and TypeScript clients
171
+ spec/ the format, versioned, with vectors
172
+ docs/ OPERATIONS, THREAT-MODEL, RESEARCH, OTEL-PROPOSAL (the console, deployment and runbooks are in underwrit-io/controlplane)
173
+ tests/ 245 tests; the new modules run each plane as a subprocess
174
+ ```
@@ -0,0 +1,156 @@
1
+ # Underwrit
2
+
3
+ Verifiable evidence for what an agent did, and a decision plane in front of it.
4
+
5
+ Two processes, and the split is the product:
6
+
7
+ | | |
8
+ |---|---|
9
+ | **data plane** — `python3 -m underwrit serve` | Runs on your side. Decides, records every decision to a hash chain, produces evidence packs. Keeps deciding when the control plane is unreachable. |
10
+ | **control plane** — `python3 -m underwrit control` | Hosted, multi-tenant. Distributes policy, counts usage. Never receives an action's arguments. Never in the decision path. |
11
+
12
+ ```
13
+ python3 -m underwrit demo-stack # both planes, the console, seeded sessions, sign-in links
14
+ python3 -m underwrit demo --live # in a second terminal: an incident held, approved by two people, claimed, verified
15
+ ```
16
+
17
+ Or with Docker: `docker compose up -d`, then `docker compose --profile demo run --rm demo`.
18
+ [`docs/DEMO.md`](docs/DEMO.md) is the twelve-minute runbook.
19
+
20
+ Or without Docker: `python3 -m underwrit control 8788`, mint a node token, then
21
+ `UNDERWRIT_CONTROL_URL=http://127.0.0.1:8788 UNDERWRIT_NODE_TOKEN=... python3 -m underwrit serve 8787`,
22
+ `UNDERWRIT_TOKEN=... python3 -m underwrit demo`, and `cd console && npm install && npm run dev`.
23
+ [`docs/OPERATIONS.md`](docs/OPERATIONS.md) has the rest.
24
+
25
+ ## Open core
26
+
27
+ This repository is the **Underwrit data plane**, licensed under Apache-2.0: the decision engine, the
28
+ hash chain, the Merkle checkpoints, the evidence format and the verifier every bundle ships, the
29
+ Python and TypeScript clients, the MCP server, the benchmark and the research notes. It runs on
30
+ its own with a local policy and produces evidence a third party can verify without trusting you —
31
+ which is the part that has to be open for the evidence to mean anything.
32
+
33
+ **Underwrit Control Plane** is licensed commercially and adds the control plane (policy distribution,
34
+ multi-tenancy, witnessing and cosignatures), the approvals console, single sign-on operations,
35
+ Helm charts, Terraform and managed deployment. It installs beside this package
36
+ (licensed commercially, shipped as container images, never on PyPI or npm) and `underwrit control` / `underwrit demo-stack` hand off to it.
37
+
38
+ ## What it does
39
+
40
+ An agent proposes an action. The plane answers with the action, everything already in that session,
41
+ and the operator's policy — `allow`, `allow_recorded`, `require_human` or `deny` — writes the
42
+ decision to a hash chain, and hands back a bundle anybody can verify offline.
43
+
44
+ Two signals decide. **Taint**: has this session consumed content a third party could have
45
+ authored? **Authority**: are the values that carry the action — recipient, amount, host, grant
46
+ target, any embedded link — named by the user, by a trusted source, or only by that content? A
47
+ tainted hold whose every such value the user named becomes a record; a value that arrived only in
48
+ untrusted content is held even for a small action.
49
+
50
+ An approval is a contract, not a flag: bound to the exact arguments, the policy version, whatever
51
+ state the caller said must still hold, and a clock. Immediately before executing, the runtime
52
+ *claims* it, and the claim is refused if anything changed, the approval expired, or it was already
53
+ used. Verification of what happened afterwards is recorded apart from whether the call succeeded.
54
+
55
+ ```
56
+ POST /v1/sessions open a session
57
+ POST /v1/decide propose an action (idempotencyKey, preconditions optional)
58
+ POST /v1/decisions/:id/resolve a person answers a held decision
59
+ POST /v1/decisions/:id/claim revalidate an approval with the same arguments, exactly once
60
+ POST /v1/outcome what happened, what came back, and what was verified
61
+ GET /v1/evidence/:id the pack
62
+ GET /v1/evidence/:id/bundle zip, with verify.py inside
63
+ POST /v1/policy/replay the shadow report: what a candidate policy would have done
64
+ GET /v1/retention POST /v1/holds what is kept, and legal holds
65
+ GET /v1/tokens POST /v1/tokens/:id/rotate|revoke
66
+ POST /v1/policy/import Cedar → deniedTools, allowlist, ceilings (preview, then apply)
67
+ GET /v1/approvers POST /v1/holds/escalate who answers, how fast; escalate overdue holds
68
+ GET /v1/checkpoint the signed tree, its witnesses and external timestamps
69
+ ```
70
+
71
+ Clients: [`sdk/python`](sdk/python) (`pip install underwrit-client`, stdlib only — twenty lines to
72
+ integrate a runtime), [`sdk/typescript`](sdk/typescript), and `python3 -m underwrit mcp` for any
73
+ MCP-capable agent. Adapters for Claude Code (`underwrit-hook`), the OpenAI Agents SDK, LangGraph,
74
+ Google ADK, the Vercel AI SDK, gateways with an HTTP pre-call hook, and OpenTelemetry.
75
+
76
+ Measured on AgentDojo with real tool outputs, over the 501 attack pairs in which the injection
77
+ produced an action: the authority check catches 436 (87%) where taint alone caught 356, and 496
78
+ (99%) with domain sinks declared; an attacker who renames the sink to an unknown tool is still
79
+ caught 397 times where a name-based check caught 21. On tasks where the user named every value
80
+ (deploys, transfers to a named account) it interrupted none of 18 sink calls; on open tasks ("read
81
+ my inbox and reply") it still asks a person most of the time, so shadow mode stays the default
82
+ there. `docs/RESEARCH.md` has the tables, the kill criteria and their limits.
83
+
84
+ Evidence is signed (Ed25519), Merkle-proven (RFC 9162), cosigned by as many witnesses as you
85
+ configure (C2SP), and time-stamped by an RFC 3161 authority and OpenTimestamps when configured;
86
+ `verify.py` in every bundle checks all of it with the standard library. Sign-in is OpenID Connect
87
+ (RS256/ES256/EdDSA) or SPIFFE JWT-SVIDs; policy can be tightened by OPA or imported from Cedar.
88
+
89
+ ## Who may act
90
+
91
+ Four roles, and the separation is the point: an **agent** proposes, an **approver** answers (two
92
+ distinct people in production), an **auditor** reads, an **admin** sets policy and mints tokens
93
+ and cannot approve. People sign in through your identity provider (OpenID Connect; a Keycloak
94
+ realm ships in `deploy/keycloak`) or with a token minted from the data plane; runtimes use tokens
95
+ or client credentials. When the provider is down, `underwrit break-glass` mints a short-lived emergency
96
+ credential from the host, and every request it makes is recorded under the operator's name.
97
+
98
+ ## Shadow mode is the default, and that is a finding not a caution
99
+
100
+ Measured against [AgentDojo](https://github.com/ethz-spylab/agentdojo) — 123 traces authored by
101
+ people who had never seen this rule — session taint caught 16 of 26 attacks while interrupting 26 of
102
+ 97 benign sessions: **one interrupt per 2.2 legitimate sink calls**, against a target of one in
103
+ twenty. Tuning detection up to 88% took it to one in 1.2. Detection and false positives moved
104
+ together, which is what a signal that does not discriminate looks like.
105
+
106
+ So the engine decides on every action and records it, and `enforce` decides whether a caller is told
107
+ to act on the verdict. Off unless an operator turns it on, per environment, after looking at their
108
+ own traffic — which is what the console's Policy view shows them before they apply a change.
109
+
110
+ ## What the evidence proves
111
+
112
+ That no entry present has been altered or reordered, no file edited, and — format 2 — that each
113
+ entry sits at its stated position in a log of the stated size, under a checkpoint signed with the
114
+ data plane's Ed25519 key. **Not** that the record is complete — only the entries present can be
115
+ checked. And not origin from the bundle alone: pin the key from `GET /v1/keys` when you verify.
116
+ Every pack says so in its own README, and `verify.py` says it again when you run it.
117
+
118
+ Arguments expire (`UNDERWRIT_RETENTION_DAYS`, per environment); the chain holds digests and is untouched,
119
+ so a pack built after a sweep verifies exactly as one built before. A legal hold exempts a subject
120
+ and is visible in its pack.
121
+
122
+ The format is in [`spec/evidence-format.md`](spec/evidence-format.md), with test vectors. It and the
123
+ verifier are MIT: an evidence format only its vendor can read is not evidence.
124
+
125
+ ## Layout
126
+
127
+ ```
128
+ underwrit/
129
+ chain.py hash-chained log — append, verify, redact, seal
130
+ evidence.py pack builder + the offline verifier
131
+ subject.py what a pack is about; the library never queries a host table
132
+ policy.py the decision engine: taint and authority
133
+ merkle.py RFC 9162 tree and proofs
134
+ ed25519.py RFC 8032, pure Python
135
+ checkpoint.py the log key and signed checkpoints
136
+ replay.py the shadow report
137
+ store.py sessions and decisions; arguments live here, digests go in the chain
138
+ retention.py sweeps, legal holds, the policy in force
139
+ auth.py roles, tokens (expiry, rotation, tenant, break glass), quorum
140
+ oidc.py OpenID Connect verification and role mapping
141
+ api.py data plane
142
+ control.py control plane — tenants, policy, fleet, usage, quota
143
+ migrate.py versioned schema
144
+ backup.py backups that end in verify_chain()
145
+ obs.py structured logs (never an argument) and /metrics
146
+ ratelimit.py per-token token bucket
147
+ mcp.py the MCP entry point
148
+ recorder.py 139-line reference recorder over a Store protocol
149
+ bundle.py zip assembly and the signed manifest; db.py the SQLite/Postgres layer
150
+ tsa.py RFC 3161 and OpenTimestamps; ecdsa_p256.py ES256; opa.py, cedar.py the policy plane
151
+ taskdraft.py a task policy drafted from the request without a model; demo.py, demo_stack.py
152
+ sdk/ Python and TypeScript clients
153
+ spec/ the format, versioned, with vectors
154
+ docs/ OPERATIONS, THREAT-MODEL, RESEARCH, OTEL-PROPOSAL (the console, deployment and runbooks are in underwrit-io/controlplane)
155
+ tests/ 245 tests; the new modules run each plane as a subprocess
156
+ ```
@@ -0,0 +1,30 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "underwrit"
7
+ version = "0.3.0"
8
+ description = "The Underwrit data plane: a decision plane for agent tool calls, and evidence anyone can verify offline. Apache-2.0."
9
+ readme = "README.md"
10
+ license = { text = "Apache-2.0" }
11
+ requires-python = ">=3.11"
12
+ dependencies = []
13
+ classifiers = [
14
+ "Programming Language :: Python :: 3",
15
+ "License :: OSI Approved :: Apache Software License",
16
+ "Topic :: Security",
17
+ "Topic :: System :: Logging",
18
+ ]
19
+
20
+ [project.optional-dependencies]
21
+ postgres = ["psycopg[binary,pool]>=3.1"]
22
+
23
+ [project.scripts]
24
+ underwrit = "underwrit.cli:main"
25
+
26
+ [project.urls]
27
+ Homepage = "https://github.com/underwrit-io/dataplane"
28
+
29
+ [tool.setuptools]
30
+ packages = ["underwrit"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+