auditgate 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.
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+ *.egg
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .pytest_cache/
12
+ .venv/
13
+ venv/
14
+ *.so
15
+ .DS_Store
@@ -0,0 +1,96 @@
1
+ Business Source License 1.1
2
+
3
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights
4
+ Reserved. “Business Source License” is a trademark of MariaDB
5
+ Corporation Ab.
6
+
7
+ ------------------------------------------------------------------------
8
+
9
+ Parameters
10
+
11
+ Licensor: actiongate-oss Licensed Work: AuditGate Additional Use Grant:
12
+ None Change Date: February 28, 2030 Change License: Mozilla Public
13
+ License 2.0
14
+
15
+ ------------------------------------------------------------------------
16
+
17
+ Terms
18
+
19
+ The Licensor hereby grants you the right to copy, modify, create
20
+ derivative works, redistribute, and make non-production use of the
21
+ Licensed Work. The Licensor may make an Additional Use Grant, above,
22
+ permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first
25
+ publicly available distribution of a specific version of the Licensed
26
+ Work under this License, whichever comes first, the Licensor hereby
27
+ grants you rights under the terms of the Change License, and the rights
28
+ granted in the paragraph above terminate.
29
+
30
+ If your use of the Licensed Work does not comply with the requirements
31
+ currently in effect as described in this License, you must purchase a
32
+ commercial license from the Licensor, its affiliated entities, or
33
+ authorized resellers, or you must refrain from using the Licensed Work.
34
+
35
+ All copies of the original and modified Licensed Work, and derivative
36
+ works of the Licensed Work, are subject to this License. This License
37
+ applies separately for each version of the Licensed Work and the Change
38
+ Date may vary for each version of the Licensed Work released by
39
+ Licensor.
40
+
41
+ You must conspicuously display this License on each original or modified
42
+ copy of the Licensed Work. If you receive the Licensed Work in original
43
+ or modified form from a third party, the terms and conditions set forth
44
+ in this License apply to your use of that work.
45
+
46
+ Any use of the Licensed Work in violation of this License will
47
+ automatically terminate your rights under this License for the current
48
+ and all other versions of the Licensed Work.
49
+
50
+ This License does not grant you any right in any trademark or logo of
51
+ Licensor or its affiliates (provided that you may use a trademark or
52
+ logo of Licensor as expressly required by this License).
53
+
54
+ TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED
55
+ ON AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND
56
+ CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION)
57
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
58
+ NON-INFRINGEMENT, AND TITLE.
59
+
60
+ MariaDB hereby grants you permission to use this License’s text to
61
+ license your works, and to refer to it using the trademark “Business
62
+ Source License”, as long as you comply with the Covenants of Licensor
63
+ below.
64
+
65
+ ------------------------------------------------------------------------
66
+
67
+ Covenants of Licensor
68
+
69
+ In consideration of the right to use this License’s text and the
70
+ “Business Source License” name and trademark, Licensor covenants to
71
+ MariaDB, and to all other recipients of the licensed work to be provided
72
+ by Licensor:
73
+
74
+ 1. To specify as the Change License the GPL Version 2.0 or any later
75
+ version, or a license that is compatible with GPL Version 2.0 or a
76
+ later version, where “compatible” means that software provided under
77
+ the Change License can be included in a program with software
78
+ provided under GPL Version 2.0 or a later version. Licensor may
79
+ specify additional Change Licenses without limitation.
80
+
81
+ 2. To either: (a) specify an additional grant of rights to use that
82
+ does not impose any additional restriction on the right granted in
83
+ this License, as the Additional Use Grant; or (b) insert the text
84
+ “None”.
85
+
86
+ 3. To specify a Change Date.
87
+
88
+ 4. Not to modify this License in any other way.
89
+
90
+ ------------------------------------------------------------------------
91
+
92
+ Notice
93
+
94
+ The Business Source License (this document, or the “License”) is not an
95
+ Open Source license. However, the Licensed Work will eventually be made
96
+ available under an Open Source License, as stated in this License.
@@ -0,0 +1,200 @@
1
+ Metadata-Version: 2.4
2
+ Name: auditgate
3
+ Version: 0.1.0
4
+ Summary: Compliance-grade audit logging for agent systems.
5
+ Project-URL: Homepage, https://github.com/actiongate-oss/auditgate
6
+ Project-URL: Documentation, https://github.com/actiongate-oss/auditgate#readme
7
+ Project-URL: Repository, https://github.com/actiongate-oss/auditgate
8
+ Author-email: ActionGate OSS <actiongate-oss@users.noreply.github.com>
9
+ License-Expression: BUSL-1.1
10
+ License-File: LICENSE
11
+ Keywords: ai-agents,audit,compliance,llm,tamper-evident
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: Other/Proprietary License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.12
20
+ Provides-Extra: dev
21
+ Requires-Dist: mypy>=1.0; extra == 'dev'
22
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
23
+ Requires-Dist: pytest>=8.0; extra == 'dev'
24
+ Requires-Dist: ruff>=0.1; extra == 'dev'
25
+ Description-Content-Type: text/markdown
26
+
27
+ # AuditGate
28
+
29
+ **Compliance-grade audit logging for agent systems.**
30
+
31
+ Every decision, every verdict, every override — structured, queryable, and tamper-evident.
32
+
33
+ ```bash
34
+ pip install auditgate
35
+ ```
36
+
37
+ ---
38
+
39
+ ## What It Does
40
+
41
+ AuditGate records every gate decision as a structured audit entry with optional tamper-evidence via content hashing or hash chaining. It pairs with [ActionGate](https://github.com/actiongate-oss/actiongate), [BudgetGate](https://github.com/actiongate-oss/budgetgate), and [RuleGate](https://github.com/actiongate-oss/rulegate) as the fourth composable primitive in the agent execution layer.
42
+
43
+ AuditGate does **not** make allow/block decisions. It records what other gates decided and guarantees the record exists.
44
+
45
+ **Vendoring encouraged.** This is a small, stable primitive. Copy it, fork it, reimplement it. If you vendor AuditGate, you must preserve the LICENSE file, preserve copyright headers in source files, and not remove or modify the BSL terms. The production use restriction applies to vendored copies. See [SEMANTICS.md](SEMANTICS.md) for the behavioral contract if you reimplement.
46
+
47
+ ## Quick Start
48
+
49
+ ```python
50
+ from auditgate import (
51
+ Engine, Trail, AuditPolicy, Verdict, Severity, IntegrityMode
52
+ )
53
+
54
+ engine = Engine()
55
+
56
+ # Define an audit trail with hash chain integrity
57
+ trail = Trail("billing", "actiongate", "user:123")
58
+ policy = AuditPolicy(integrity=IntegrityMode.CHAIN)
59
+ engine.register(trail, policy)
60
+
61
+ # Record a decision from ActionGate
62
+ decision = engine.record(
63
+ trail=trail,
64
+ verdict=Verdict.ALLOW,
65
+ severity=Severity.INFO,
66
+ gate_type="actiongate",
67
+ gate_identity="billing:refund@user:123",
68
+ reason="Rate limit check passed",
69
+ detail={"calls_in_window": 3, "max_calls": 10},
70
+ )
71
+
72
+ assert decision.recorded
73
+ assert decision.entry.entry_hash is not None
74
+ ```
75
+
76
+ ## Integrity Modes
77
+
78
+ | Mode | Behavior | Use Case |
79
+ |---------|----------|----------|
80
+ | `NONE` | No hashing | Maximum throughput, trust the store |
81
+ | `HASH` | SHA-256 per entry | Detect tampering of individual entries |
82
+ | `CHAIN` | Hash includes previous entry's hash | Detect tampering or deletion of any entry |
83
+
84
+ ## Failure Modes
85
+
86
+ | Policy | Behavior |
87
+ |--------|----------|
88
+ | `HARD` + `FAIL_CLOSED` | No action can proceed without a recorded audit entry |
89
+ | `HARD` + `FAIL_OPEN` | Raises on failure but allows unaudited actions |
90
+ | `SOFT` + `FAIL_CLOSED` | Returns DROPPED decision, caller decides |
91
+ | `SOFT` + `FAIL_OPEN` | Fire-and-forget audit (best-effort) |
92
+
93
+ ## Decorator API
94
+
95
+ ```python
96
+ # Raises AuditError if audit recording fails (HARD mode default)
97
+ @engine.guard(
98
+ Trail("api", "combined", "global"),
99
+ policy=AuditPolicy(integrity=IntegrityMode.HASH),
100
+ severity=Severity.INFO,
101
+ gate_type="auditgate",
102
+ )
103
+ def process_order(order_id: str) -> dict:
104
+ return {"status": "processed", "id": order_id}
105
+
106
+ # Or use guard_result for no-exception handling
107
+ @engine.guard_result(
108
+ Trail("api", "combined", "global"),
109
+ policy=AuditPolicy(mode=Mode.SOFT),
110
+ severity=Severity.INFO,
111
+ gate_type="auditgate",
112
+ )
113
+ def fetch_data(query: str) -> list:
114
+ return db.search(query)
115
+
116
+ result = fetch_data(query="recent orders")
117
+ data = result.unwrap_or([])
118
+ ```
119
+
120
+ ## Querying the Audit Trail
121
+
122
+ ```python
123
+ from auditgate import QueryFilter, Verdict, Severity
124
+
125
+ # All blocked decisions in the last hour
126
+ entries = engine._store.query(QueryFilter(
127
+ trail=trail,
128
+ verdict=Verdict.BLOCK,
129
+ after_ts=time.monotonic() - 3600,
130
+ ))
131
+
132
+ # All critical events across all trails
133
+ critical = engine._store.query(QueryFilter(
134
+ min_severity=Severity.CRITICAL,
135
+ ))
136
+ ```
137
+
138
+ ## Composing with Other Gates
139
+
140
+ ```python
141
+ from actiongate import Engine as ActionEngine, Gate, Policy
142
+ from auditgate import Engine as AuditEngine, Trail, AuditPolicy, Verdict, Severity
143
+
144
+ action_engine = ActionEngine()
145
+ audit_engine = AuditEngine()
146
+
147
+ trail = Trail("api", "actiongate", "global")
148
+ audit_engine.register(trail, AuditPolicy())
149
+
150
+ # Listen to ActionGate decisions and auto-audit them
151
+ def audit_listener(action_decision):
152
+ audit_engine.record(
153
+ trail=trail,
154
+ verdict=Verdict.ALLOW if action_decision.allowed else Verdict.BLOCK,
155
+ severity=Severity.INFO if action_decision.allowed else Severity.WARN,
156
+ gate_type="actiongate",
157
+ gate_identity=str(action_decision.gate),
158
+ reason=str(action_decision.reason) if action_decision.reason else None,
159
+ )
160
+
161
+ action_engine.on_decision(audit_listener)
162
+ ```
163
+
164
+ ## Performance
165
+
166
+ Sub-20µs per audit entry with MemoryStore and SHA-256 hashing (benchmarked). Hash chain mode adds negligible overhead. For context, a single LLM API call is 200ms–2s.
167
+
168
+ ## File Structure
169
+
170
+ ```
171
+ auditgate/
172
+ ├── __init__.py # Public API, exports, version
173
+ ├── core.py # All value types (Trail, AuditPolicy, AuditEntry, Decision, Result)
174
+ ├── engine.py # Engine class (record, guard, guard_result)
175
+ └── store.py # Store protocol + MemoryStore
176
+ ```
177
+
178
+ ## Specification
179
+
180
+ See [SEMANTICS.md](SEMANTICS.md) for the normative behavior specification. When this document and the code conflict, the specification governs.
181
+
182
+ ## License
183
+
184
+ AuditGate is licensed under the [Business Source License 1.1](LICENSE).
185
+
186
+ ```
187
+ Licensor: actiongate-oss
188
+ Licensed Work: AuditGate
189
+ Additional Use Grant: None
190
+ Change Date: 2030-02-28 (four years from initial publication)
191
+ Change License: Mozilla Public License 2.0
192
+ ```
193
+
194
+ **What this means:** You may copy, modify, create derivative works, redistribute, and make non-production use of AuditGate. The Additional Use Grant is "None", which means any use in a live environment that provides value to end users or internal business operations — including SaaS, internal enterprise deployment, and paid betas — requires a commercial license from the licensor. On the Change Date, AuditGate becomes available under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/) and the production restriction terminates. Each version has its own Change Date calculated from its publication.
195
+
196
+ **If you vendor AuditGate:** Preserve the LICENSE file and copyright headers. Do not remove or modify the BSL terms. The production restriction applies to all copies, vendored or otherwise.
197
+
198
+ **Licensing difference from siblings:** [ActionGate](https://github.com/actiongate-oss/actiongate) and [BudgetGate](https://github.com/actiongate-oss/budgetgate) are Apache 2.0. AuditGate is BSL 1.1. If composing all three, ensure your use complies with both license terms.
199
+
200
+ See [LICENSE](LICENSE) for the legally binding text.
@@ -0,0 +1,174 @@
1
+ # AuditGate
2
+
3
+ **Compliance-grade audit logging for agent systems.**
4
+
5
+ Every decision, every verdict, every override — structured, queryable, and tamper-evident.
6
+
7
+ ```bash
8
+ pip install auditgate
9
+ ```
10
+
11
+ ---
12
+
13
+ ## What It Does
14
+
15
+ AuditGate records every gate decision as a structured audit entry with optional tamper-evidence via content hashing or hash chaining. It pairs with [ActionGate](https://github.com/actiongate-oss/actiongate), [BudgetGate](https://github.com/actiongate-oss/budgetgate), and [RuleGate](https://github.com/actiongate-oss/rulegate) as the fourth composable primitive in the agent execution layer.
16
+
17
+ AuditGate does **not** make allow/block decisions. It records what other gates decided and guarantees the record exists.
18
+
19
+ **Vendoring encouraged.** This is a small, stable primitive. Copy it, fork it, reimplement it. If you vendor AuditGate, you must preserve the LICENSE file, preserve copyright headers in source files, and not remove or modify the BSL terms. The production use restriction applies to vendored copies. See [SEMANTICS.md](SEMANTICS.md) for the behavioral contract if you reimplement.
20
+
21
+ ## Quick Start
22
+
23
+ ```python
24
+ from auditgate import (
25
+ Engine, Trail, AuditPolicy, Verdict, Severity, IntegrityMode
26
+ )
27
+
28
+ engine = Engine()
29
+
30
+ # Define an audit trail with hash chain integrity
31
+ trail = Trail("billing", "actiongate", "user:123")
32
+ policy = AuditPolicy(integrity=IntegrityMode.CHAIN)
33
+ engine.register(trail, policy)
34
+
35
+ # Record a decision from ActionGate
36
+ decision = engine.record(
37
+ trail=trail,
38
+ verdict=Verdict.ALLOW,
39
+ severity=Severity.INFO,
40
+ gate_type="actiongate",
41
+ gate_identity="billing:refund@user:123",
42
+ reason="Rate limit check passed",
43
+ detail={"calls_in_window": 3, "max_calls": 10},
44
+ )
45
+
46
+ assert decision.recorded
47
+ assert decision.entry.entry_hash is not None
48
+ ```
49
+
50
+ ## Integrity Modes
51
+
52
+ | Mode | Behavior | Use Case |
53
+ |---------|----------|----------|
54
+ | `NONE` | No hashing | Maximum throughput, trust the store |
55
+ | `HASH` | SHA-256 per entry | Detect tampering of individual entries |
56
+ | `CHAIN` | Hash includes previous entry's hash | Detect tampering or deletion of any entry |
57
+
58
+ ## Failure Modes
59
+
60
+ | Policy | Behavior |
61
+ |--------|----------|
62
+ | `HARD` + `FAIL_CLOSED` | No action can proceed without a recorded audit entry |
63
+ | `HARD` + `FAIL_OPEN` | Raises on failure but allows unaudited actions |
64
+ | `SOFT` + `FAIL_CLOSED` | Returns DROPPED decision, caller decides |
65
+ | `SOFT` + `FAIL_OPEN` | Fire-and-forget audit (best-effort) |
66
+
67
+ ## Decorator API
68
+
69
+ ```python
70
+ # Raises AuditError if audit recording fails (HARD mode default)
71
+ @engine.guard(
72
+ Trail("api", "combined", "global"),
73
+ policy=AuditPolicy(integrity=IntegrityMode.HASH),
74
+ severity=Severity.INFO,
75
+ gate_type="auditgate",
76
+ )
77
+ def process_order(order_id: str) -> dict:
78
+ return {"status": "processed", "id": order_id}
79
+
80
+ # Or use guard_result for no-exception handling
81
+ @engine.guard_result(
82
+ Trail("api", "combined", "global"),
83
+ policy=AuditPolicy(mode=Mode.SOFT),
84
+ severity=Severity.INFO,
85
+ gate_type="auditgate",
86
+ )
87
+ def fetch_data(query: str) -> list:
88
+ return db.search(query)
89
+
90
+ result = fetch_data(query="recent orders")
91
+ data = result.unwrap_or([])
92
+ ```
93
+
94
+ ## Querying the Audit Trail
95
+
96
+ ```python
97
+ from auditgate import QueryFilter, Verdict, Severity
98
+
99
+ # All blocked decisions in the last hour
100
+ entries = engine._store.query(QueryFilter(
101
+ trail=trail,
102
+ verdict=Verdict.BLOCK,
103
+ after_ts=time.monotonic() - 3600,
104
+ ))
105
+
106
+ # All critical events across all trails
107
+ critical = engine._store.query(QueryFilter(
108
+ min_severity=Severity.CRITICAL,
109
+ ))
110
+ ```
111
+
112
+ ## Composing with Other Gates
113
+
114
+ ```python
115
+ from actiongate import Engine as ActionEngine, Gate, Policy
116
+ from auditgate import Engine as AuditEngine, Trail, AuditPolicy, Verdict, Severity
117
+
118
+ action_engine = ActionEngine()
119
+ audit_engine = AuditEngine()
120
+
121
+ trail = Trail("api", "actiongate", "global")
122
+ audit_engine.register(trail, AuditPolicy())
123
+
124
+ # Listen to ActionGate decisions and auto-audit them
125
+ def audit_listener(action_decision):
126
+ audit_engine.record(
127
+ trail=trail,
128
+ verdict=Verdict.ALLOW if action_decision.allowed else Verdict.BLOCK,
129
+ severity=Severity.INFO if action_decision.allowed else Severity.WARN,
130
+ gate_type="actiongate",
131
+ gate_identity=str(action_decision.gate),
132
+ reason=str(action_decision.reason) if action_decision.reason else None,
133
+ )
134
+
135
+ action_engine.on_decision(audit_listener)
136
+ ```
137
+
138
+ ## Performance
139
+
140
+ Sub-20µs per audit entry with MemoryStore and SHA-256 hashing (benchmarked). Hash chain mode adds negligible overhead. For context, a single LLM API call is 200ms–2s.
141
+
142
+ ## File Structure
143
+
144
+ ```
145
+ auditgate/
146
+ ├── __init__.py # Public API, exports, version
147
+ ├── core.py # All value types (Trail, AuditPolicy, AuditEntry, Decision, Result)
148
+ ├── engine.py # Engine class (record, guard, guard_result)
149
+ └── store.py # Store protocol + MemoryStore
150
+ ```
151
+
152
+ ## Specification
153
+
154
+ See [SEMANTICS.md](SEMANTICS.md) for the normative behavior specification. When this document and the code conflict, the specification governs.
155
+
156
+ ## License
157
+
158
+ AuditGate is licensed under the [Business Source License 1.1](LICENSE).
159
+
160
+ ```
161
+ Licensor: actiongate-oss
162
+ Licensed Work: AuditGate
163
+ Additional Use Grant: None
164
+ Change Date: 2030-02-28 (four years from initial publication)
165
+ Change License: Mozilla Public License 2.0
166
+ ```
167
+
168
+ **What this means:** You may copy, modify, create derivative works, redistribute, and make non-production use of AuditGate. The Additional Use Grant is "None", which means any use in a live environment that provides value to end users or internal business operations — including SaaS, internal enterprise deployment, and paid betas — requires a commercial license from the licensor. On the Change Date, AuditGate becomes available under [MPL 2.0](https://www.mozilla.org/en-US/MPL/2.0/) and the production restriction terminates. Each version has its own Change Date calculated from its publication.
169
+
170
+ **If you vendor AuditGate:** Preserve the LICENSE file and copyright headers. Do not remove or modify the BSL terms. The production restriction applies to all copies, vendored or otherwise.
171
+
172
+ **Licensing difference from siblings:** [ActionGate](https://github.com/actiongate-oss/actiongate) and [BudgetGate](https://github.com/actiongate-oss/budgetgate) are Apache 2.0. AuditGate is BSL 1.1. If composing all three, ensure your use complies with both license terms.
173
+
174
+ See [LICENSE](LICENSE) for the legally binding text.