aegis-runtime 0.2.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.
- aegis_runtime-0.2.0/LICENSE +21 -0
- aegis_runtime-0.2.0/PKG-INFO +105 -0
- aegis_runtime-0.2.0/README.md +88 -0
- aegis_runtime-0.2.0/pyproject.toml +25 -0
- aegis_runtime-0.2.0/setup.cfg +4 -0
- aegis_runtime-0.2.0/src/aegis_runtime/__init__.py +4 -0
- aegis_runtime-0.2.0/src/aegis_runtime/core.py +90 -0
- aegis_runtime-0.2.0/src/aegis_runtime.egg-info/PKG-INFO +105 -0
- aegis_runtime-0.2.0/src/aegis_runtime.egg-info/SOURCES.txt +10 -0
- aegis_runtime-0.2.0/src/aegis_runtime.egg-info/dependency_links.txt +1 -0
- aegis_runtime-0.2.0/src/aegis_runtime.egg-info/requires.txt +3 -0
- aegis_runtime-0.2.0/src/aegis_runtime.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aegis Runtime Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aegis-runtime
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Zero-trust deterministic flight controller for AI agents: circuit breakers, state locks, atomic rollbacks, and SHA-256 audit logs.
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: ai,agents,security,llm,guardrails,deterministic,runtime
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: groq
|
|
15
|
+
Requires-Dist: groq>=0.9.0; extra == "groq"
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# 🛡️ Aegis Runtime (`aegis-runtime`)
|
|
19
|
+
|
|
20
|
+
**The zero-trust deterministic flight controller for AI agents.**
|
|
21
|
+
|
|
22
|
+
Enterprises refuse to deploy fully autonomous AI agents in production because probabilistic LLMs suffer from three fatal flaws:
|
|
23
|
+
1. **Prompt Injections & Unauthorized Actions:** Malicious inputs trick agents into wiring funds, issuing refunds, or deleting records.
|
|
24
|
+
2. **Infinite Loops & Partial Corruption:** Agents spiral in tool-call loops or crash mid-workflow, leaving databases in corrupted states.
|
|
25
|
+
3. **Zero Compliance Guarantees:** Regulated industries (fintech, healthcare, legal) require deterministic code enforcement and tamper-proof audit trails—not probabilistic "hope."
|
|
26
|
+
|
|
27
|
+
**Aegis treats the LLM like a brilliant, erratic intern.** Every tool call is wrapped in deterministic Python code (`@aegis.guard` and `@aegis.transaction`) that enforces hard mathematical guarantees before any side effect touches your infrastructure.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## ⚡ Core Capabilities
|
|
32
|
+
|
|
33
|
+
* **Deterministic State Locks:** Enforce code-level prerequisites (`issue_refund` cannot execute unless `verify_customer` succeeded in the same session).
|
|
34
|
+
* **Circuit Breakers:** Hard execution caps on repetitive tool calls to kill infinite loops instantly.
|
|
35
|
+
* **Atomic Time-Travel Rollbacks:** Automatic state snapshots before multi-step workflows—if Step 3 fails, Steps 1 and 2 rewind automatically.
|
|
36
|
+
* **Cryptographic Audit Logs:** Every allowed or blocked tool execution generates a tamper-proof **SHA-256 hash receipt**.
|
|
37
|
+
* **Zero External Dependencies:** Pure Python standard library core (`0` bloated dependencies).
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🚀 Quickstart
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install aegis-runtime
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from aegis_runtime import AegisRuntime, SecurityViolation
|
|
49
|
+
|
|
50
|
+
aegis = AegisRuntime()
|
|
51
|
+
|
|
52
|
+
@aegis.guard(max_calls=3)
|
|
53
|
+
def verify_customer(email: str) -> str:
|
|
54
|
+
aegis.set_state("customer_verified", True)
|
|
55
|
+
return f"Verified {email}"
|
|
56
|
+
|
|
57
|
+
@aegis.guard(requires=["customer_verified"])
|
|
58
|
+
def issue_refund(amount: float, email: str) -> str:
|
|
59
|
+
return f"Refunded ${amount} to {email}"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🔥 Live Proof: Neutralizing an Indirect Prompt Injection
|
|
65
|
+
|
|
66
|
+
In `examples/live_agent.py`, a 120B frontier LLM is compromised by a hidden CRM metadata injection attempting to bypass customer verification and send **\$5,000**. Aegis intercepts the compromised tool call in deterministic Python and logs a SHA-256 receipt:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
[AI ATTEMPTED TOOL CALL] issue_refund({'amount': 5000, 'email': 'sarah.m@gmail.com'})
|
|
70
|
+
|
|
71
|
+
[AEGIS SHIELD ACTIVATED] Live AI Compromised, Attack Neutralized!
|
|
72
|
+
Reason: Policy violation: issue_refund requires customer_verified=True
|
|
73
|
+
|
|
74
|
+
Cryptographic Audit Log:
|
|
75
|
+
{'timestamp': 1795043630.3087144, 'tool': 'issue_refund', 'status': 'BLOCKED_POLICY', 'args': '()', 'hash': 'c58f693e73d0032529ce47cb9d9ad6a664cc73368f6f9e919719727b6909a23d'}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 🧪 Running the Examples
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# 1. Test deterministic blocking of unauthorized database deletion
|
|
84
|
+
python examples/test_attack.py
|
|
85
|
+
|
|
86
|
+
# 2. Test atomic time-travel state rollback on mid-transaction failure
|
|
87
|
+
python examples/test_rollback.py
|
|
88
|
+
|
|
89
|
+
# 3. Test live prompt injection defense against an LLM (requires GROQ_API_KEY in .env)
|
|
90
|
+
pip install groq
|
|
91
|
+
python examples/live_agent.py
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 🗺️ Roadmap
|
|
97
|
+
|
|
98
|
+
- [x] **v0.2:** Deterministic State Locks, Circuit Breakers, Atomic Rollbacks, SHA-256 Audit Receipts
|
|
99
|
+
- [ ] **v0.3:** Native adapters for OpenAI, Anthropic, LangGraph, and CrewAI
|
|
100
|
+
- [ ] **v0.4:** Policy-as-Code YAML/JSON configurations & CLI audit verifier
|
|
101
|
+
- [ ] **Aegis Cloud:** Real-time fleet observability, live human-in-the-loop approvals, and one-click replay
|
|
102
|
+
|
|
103
|
+
## 📄 License
|
|
104
|
+
|
|
105
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# 🛡️ Aegis Runtime (`aegis-runtime`)
|
|
2
|
+
|
|
3
|
+
**The zero-trust deterministic flight controller for AI agents.**
|
|
4
|
+
|
|
5
|
+
Enterprises refuse to deploy fully autonomous AI agents in production because probabilistic LLMs suffer from three fatal flaws:
|
|
6
|
+
1. **Prompt Injections & Unauthorized Actions:** Malicious inputs trick agents into wiring funds, issuing refunds, or deleting records.
|
|
7
|
+
2. **Infinite Loops & Partial Corruption:** Agents spiral in tool-call loops or crash mid-workflow, leaving databases in corrupted states.
|
|
8
|
+
3. **Zero Compliance Guarantees:** Regulated industries (fintech, healthcare, legal) require deterministic code enforcement and tamper-proof audit trails—not probabilistic "hope."
|
|
9
|
+
|
|
10
|
+
**Aegis treats the LLM like a brilliant, erratic intern.** Every tool call is wrapped in deterministic Python code (`@aegis.guard` and `@aegis.transaction`) that enforces hard mathematical guarantees before any side effect touches your infrastructure.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## ⚡ Core Capabilities
|
|
15
|
+
|
|
16
|
+
* **Deterministic State Locks:** Enforce code-level prerequisites (`issue_refund` cannot execute unless `verify_customer` succeeded in the same session).
|
|
17
|
+
* **Circuit Breakers:** Hard execution caps on repetitive tool calls to kill infinite loops instantly.
|
|
18
|
+
* **Atomic Time-Travel Rollbacks:** Automatic state snapshots before multi-step workflows—if Step 3 fails, Steps 1 and 2 rewind automatically.
|
|
19
|
+
* **Cryptographic Audit Logs:** Every allowed or blocked tool execution generates a tamper-proof **SHA-256 hash receipt**.
|
|
20
|
+
* **Zero External Dependencies:** Pure Python standard library core (`0` bloated dependencies).
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 🚀 Quickstart
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install aegis-runtime
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from aegis_runtime import AegisRuntime, SecurityViolation
|
|
32
|
+
|
|
33
|
+
aegis = AegisRuntime()
|
|
34
|
+
|
|
35
|
+
@aegis.guard(max_calls=3)
|
|
36
|
+
def verify_customer(email: str) -> str:
|
|
37
|
+
aegis.set_state("customer_verified", True)
|
|
38
|
+
return f"Verified {email}"
|
|
39
|
+
|
|
40
|
+
@aegis.guard(requires=["customer_verified"])
|
|
41
|
+
def issue_refund(amount: float, email: str) -> str:
|
|
42
|
+
return f"Refunded ${amount} to {email}"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 🔥 Live Proof: Neutralizing an Indirect Prompt Injection
|
|
48
|
+
|
|
49
|
+
In `examples/live_agent.py`, a 120B frontier LLM is compromised by a hidden CRM metadata injection attempting to bypass customer verification and send **\$5,000**. Aegis intercepts the compromised tool call in deterministic Python and logs a SHA-256 receipt:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
[AI ATTEMPTED TOOL CALL] issue_refund({'amount': 5000, 'email': 'sarah.m@gmail.com'})
|
|
53
|
+
|
|
54
|
+
[AEGIS SHIELD ACTIVATED] Live AI Compromised, Attack Neutralized!
|
|
55
|
+
Reason: Policy violation: issue_refund requires customer_verified=True
|
|
56
|
+
|
|
57
|
+
Cryptographic Audit Log:
|
|
58
|
+
{'timestamp': 1795043630.3087144, 'tool': 'issue_refund', 'status': 'BLOCKED_POLICY', 'args': '()', 'hash': 'c58f693e73d0032529ce47cb9d9ad6a664cc73368f6f9e919719727b6909a23d'}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 🧪 Running the Examples
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# 1. Test deterministic blocking of unauthorized database deletion
|
|
67
|
+
python examples/test_attack.py
|
|
68
|
+
|
|
69
|
+
# 2. Test atomic time-travel state rollback on mid-transaction failure
|
|
70
|
+
python examples/test_rollback.py
|
|
71
|
+
|
|
72
|
+
# 3. Test live prompt injection defense against an LLM (requires GROQ_API_KEY in .env)
|
|
73
|
+
pip install groq
|
|
74
|
+
python examples/live_agent.py
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 🗺️ Roadmap
|
|
80
|
+
|
|
81
|
+
- [x] **v0.2:** Deterministic State Locks, Circuit Breakers, Atomic Rollbacks, SHA-256 Audit Receipts
|
|
82
|
+
- [ ] **v0.3:** Native adapters for OpenAI, Anthropic, LangGraph, and CrewAI
|
|
83
|
+
- [ ] **v0.4:** Policy-as-Code YAML/JSON configurations & CLI audit verifier
|
|
84
|
+
- [ ] **Aegis Cloud:** Real-time fleet observability, live human-in-the-loop approvals, and one-click replay
|
|
85
|
+
|
|
86
|
+
## 📄 License
|
|
87
|
+
|
|
88
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "aegis-runtime"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Zero-trust deterministic flight controller for AI agents: circuit breakers, state locks, atomic rollbacks, and SHA-256 audit logs."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
keywords = ["ai", "agents", "security", "llm", "guardrails", "deterministic", "runtime"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
]
|
|
19
|
+
dependencies = []
|
|
20
|
+
|
|
21
|
+
[project.optional-dependencies]
|
|
22
|
+
groq = ["groq>=0.9.0"]
|
|
23
|
+
|
|
24
|
+
[tool.setuptools.packages.find]
|
|
25
|
+
where = ["src"]
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import copy
|
|
2
|
+
import hashlib
|
|
3
|
+
import json
|
|
4
|
+
import time
|
|
5
|
+
from functools import wraps
|
|
6
|
+
|
|
7
|
+
class SecurityViolation(Exception):
|
|
8
|
+
pass
|
|
9
|
+
|
|
10
|
+
class AegisRuntime:
|
|
11
|
+
def __init__(self, max_calls=5, state_store=None):
|
|
12
|
+
self.max_calls = max_calls
|
|
13
|
+
self.call_counts = {}
|
|
14
|
+
self.session_state = {}
|
|
15
|
+
self.audit_log = []
|
|
16
|
+
self.state_store = state_store if state_store is not None else {}
|
|
17
|
+
self.snapshots = []
|
|
18
|
+
|
|
19
|
+
def _log_event(self, tool_name, status, args):
|
|
20
|
+
entry = {
|
|
21
|
+
"timestamp": time.time(),
|
|
22
|
+
"tool": tool_name,
|
|
23
|
+
"status": status,
|
|
24
|
+
"args": str(args)
|
|
25
|
+
}
|
|
26
|
+
entry_hash = hashlib.sha256(json.dumps(entry).encode()).hexdigest()
|
|
27
|
+
entry["hash"] = entry_hash
|
|
28
|
+
self.audit_log.append(entry)
|
|
29
|
+
|
|
30
|
+
def create_checkpoint(self, label):
|
|
31
|
+
snapshot = copy.deepcopy(self.state_store)
|
|
32
|
+
self.snapshots.append((label, snapshot))
|
|
33
|
+
self._log_event("SYSTEM_CHECKPOINT", "SAVED", label)
|
|
34
|
+
|
|
35
|
+
def rollback_to(self, target_label=None):
|
|
36
|
+
if not self.snapshots:
|
|
37
|
+
return False
|
|
38
|
+
while self.snapshots:
|
|
39
|
+
label, previous_state = self.snapshots.pop()
|
|
40
|
+
if target_label is None or label == target_label:
|
|
41
|
+
self.state_store.clear()
|
|
42
|
+
self.state_store.update(previous_state)
|
|
43
|
+
self._log_event("SYSTEM_ROLLBACK", "RESTORED", label)
|
|
44
|
+
return label
|
|
45
|
+
return False
|
|
46
|
+
|
|
47
|
+
def transaction(self, tx_name="agent_workflow"):
|
|
48
|
+
"""Wraps an entire multi-step agent workflow. If ANY step fails, the entire workflow rewinds to zero."""
|
|
49
|
+
def decorator(func):
|
|
50
|
+
@wraps(func)
|
|
51
|
+
def wrapper(*args, **kwargs):
|
|
52
|
+
tx_label = f"TX_START_{tx_name}"
|
|
53
|
+
self.create_checkpoint(tx_label)
|
|
54
|
+
try:
|
|
55
|
+
result = func(*args, **kwargs)
|
|
56
|
+
self._log_event(tx_name, "TX_COMMITTED", args)
|
|
57
|
+
return result
|
|
58
|
+
except Exception as e:
|
|
59
|
+
restored = self.rollback_to(tx_label)
|
|
60
|
+
print(f"[AEGIS ATOMIC ROLLBACK] Workflow '{tx_name}' failed. Rewound all steps back to '{restored}'.")
|
|
61
|
+
raise e
|
|
62
|
+
return wrapper
|
|
63
|
+
return decorator
|
|
64
|
+
|
|
65
|
+
def guard(self, requires_state=None, sets_state=None):
|
|
66
|
+
def decorator(func):
|
|
67
|
+
@wraps(func)
|
|
68
|
+
def wrapper(*args, **kwargs):
|
|
69
|
+
tool_name = func.__name__
|
|
70
|
+
|
|
71
|
+
# 1. Circuit Breaker
|
|
72
|
+
self.call_counts[tool_name] = self.call_counts.get(tool_name, 0) + 1
|
|
73
|
+
if self.call_counts[tool_name] > self.max_calls:
|
|
74
|
+
self._log_event(tool_name, "BLOCKED_LOOP", args)
|
|
75
|
+
raise SecurityViolation(f"Circuit breaker tripped: {tool_name} exceeded {self.max_calls} calls.")
|
|
76
|
+
|
|
77
|
+
# 2. Deterministic State Lock
|
|
78
|
+
if requires_state:
|
|
79
|
+
for key, expected_val in requires_state.items():
|
|
80
|
+
if self.session_state.get(key) != expected_val:
|
|
81
|
+
self._log_event(tool_name, "BLOCKED_POLICY", args)
|
|
82
|
+
raise SecurityViolation(f"Policy violation: {tool_name} requires {key}={expected_val}")
|
|
83
|
+
|
|
84
|
+
result = func(*args, **kwargs)
|
|
85
|
+
self._log_event(tool_name, "EXECUTED", args)
|
|
86
|
+
if sets_state:
|
|
87
|
+
self.session_state.update(sets_state)
|
|
88
|
+
return result
|
|
89
|
+
return wrapper
|
|
90
|
+
return decorator
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: aegis-runtime
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Zero-trust deterministic flight controller for AI agents: circuit breakers, state locks, atomic rollbacks, and SHA-256 audit logs.
|
|
5
|
+
License: MIT
|
|
6
|
+
Keywords: ai,agents,security,llm,guardrails,deterministic,runtime
|
|
7
|
+
Classifier: Development Status :: 3 - Alpha
|
|
8
|
+
Classifier: Intended Audience :: Developers
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Provides-Extra: groq
|
|
15
|
+
Requires-Dist: groq>=0.9.0; extra == "groq"
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# 🛡️ Aegis Runtime (`aegis-runtime`)
|
|
19
|
+
|
|
20
|
+
**The zero-trust deterministic flight controller for AI agents.**
|
|
21
|
+
|
|
22
|
+
Enterprises refuse to deploy fully autonomous AI agents in production because probabilistic LLMs suffer from three fatal flaws:
|
|
23
|
+
1. **Prompt Injections & Unauthorized Actions:** Malicious inputs trick agents into wiring funds, issuing refunds, or deleting records.
|
|
24
|
+
2. **Infinite Loops & Partial Corruption:** Agents spiral in tool-call loops or crash mid-workflow, leaving databases in corrupted states.
|
|
25
|
+
3. **Zero Compliance Guarantees:** Regulated industries (fintech, healthcare, legal) require deterministic code enforcement and tamper-proof audit trails—not probabilistic "hope."
|
|
26
|
+
|
|
27
|
+
**Aegis treats the LLM like a brilliant, erratic intern.** Every tool call is wrapped in deterministic Python code (`@aegis.guard` and `@aegis.transaction`) that enforces hard mathematical guarantees before any side effect touches your infrastructure.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## ⚡ Core Capabilities
|
|
32
|
+
|
|
33
|
+
* **Deterministic State Locks:** Enforce code-level prerequisites (`issue_refund` cannot execute unless `verify_customer` succeeded in the same session).
|
|
34
|
+
* **Circuit Breakers:** Hard execution caps on repetitive tool calls to kill infinite loops instantly.
|
|
35
|
+
* **Atomic Time-Travel Rollbacks:** Automatic state snapshots before multi-step workflows—if Step 3 fails, Steps 1 and 2 rewind automatically.
|
|
36
|
+
* **Cryptographic Audit Logs:** Every allowed or blocked tool execution generates a tamper-proof **SHA-256 hash receipt**.
|
|
37
|
+
* **Zero External Dependencies:** Pure Python standard library core (`0` bloated dependencies).
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## 🚀 Quickstart
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install aegis-runtime
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from aegis_runtime import AegisRuntime, SecurityViolation
|
|
49
|
+
|
|
50
|
+
aegis = AegisRuntime()
|
|
51
|
+
|
|
52
|
+
@aegis.guard(max_calls=3)
|
|
53
|
+
def verify_customer(email: str) -> str:
|
|
54
|
+
aegis.set_state("customer_verified", True)
|
|
55
|
+
return f"Verified {email}"
|
|
56
|
+
|
|
57
|
+
@aegis.guard(requires=["customer_verified"])
|
|
58
|
+
def issue_refund(amount: float, email: str) -> str:
|
|
59
|
+
return f"Refunded ${amount} to {email}"
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 🔥 Live Proof: Neutralizing an Indirect Prompt Injection
|
|
65
|
+
|
|
66
|
+
In `examples/live_agent.py`, a 120B frontier LLM is compromised by a hidden CRM metadata injection attempting to bypass customer verification and send **\$5,000**. Aegis intercepts the compromised tool call in deterministic Python and logs a SHA-256 receipt:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
[AI ATTEMPTED TOOL CALL] issue_refund({'amount': 5000, 'email': 'sarah.m@gmail.com'})
|
|
70
|
+
|
|
71
|
+
[AEGIS SHIELD ACTIVATED] Live AI Compromised, Attack Neutralized!
|
|
72
|
+
Reason: Policy violation: issue_refund requires customer_verified=True
|
|
73
|
+
|
|
74
|
+
Cryptographic Audit Log:
|
|
75
|
+
{'timestamp': 1795043630.3087144, 'tool': 'issue_refund', 'status': 'BLOCKED_POLICY', 'args': '()', 'hash': 'c58f693e73d0032529ce47cb9d9ad6a664cc73368f6f9e919719727b6909a23d'}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## 🧪 Running the Examples
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# 1. Test deterministic blocking of unauthorized database deletion
|
|
84
|
+
python examples/test_attack.py
|
|
85
|
+
|
|
86
|
+
# 2. Test atomic time-travel state rollback on mid-transaction failure
|
|
87
|
+
python examples/test_rollback.py
|
|
88
|
+
|
|
89
|
+
# 3. Test live prompt injection defense against an LLM (requires GROQ_API_KEY in .env)
|
|
90
|
+
pip install groq
|
|
91
|
+
python examples/live_agent.py
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 🗺️ Roadmap
|
|
97
|
+
|
|
98
|
+
- [x] **v0.2:** Deterministic State Locks, Circuit Breakers, Atomic Rollbacks, SHA-256 Audit Receipts
|
|
99
|
+
- [ ] **v0.3:** Native adapters for OpenAI, Anthropic, LangGraph, and CrewAI
|
|
100
|
+
- [ ] **v0.4:** Policy-as-Code YAML/JSON configurations & CLI audit verifier
|
|
101
|
+
- [ ] **Aegis Cloud:** Real-time fleet observability, live human-in-the-loop approvals, and one-click replay
|
|
102
|
+
|
|
103
|
+
## 📄 License
|
|
104
|
+
|
|
105
|
+
MIT License — see [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
src/aegis_runtime/__init__.py
|
|
5
|
+
src/aegis_runtime/core.py
|
|
6
|
+
src/aegis_runtime.egg-info/PKG-INFO
|
|
7
|
+
src/aegis_runtime.egg-info/SOURCES.txt
|
|
8
|
+
src/aegis_runtime.egg-info/dependency_links.txt
|
|
9
|
+
src/aegis_runtime.egg-info/requires.txt
|
|
10
|
+
src/aegis_runtime.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
aegis_runtime
|