antraft 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.
- antraft-0.1.0/LICENSE +21 -0
- antraft-0.1.0/PKG-INFO +198 -0
- antraft-0.1.0/README.md +155 -0
- antraft-0.1.0/antraft/__init__.py +0 -0
- antraft-0.1.0/antraft.egg-info/PKG-INFO +198 -0
- antraft-0.1.0/antraft.egg-info/SOURCES.txt +12 -0
- antraft-0.1.0/antraft.egg-info/dependency_links.txt +1 -0
- antraft-0.1.0/antraft.egg-info/requires.txt +4 -0
- antraft-0.1.0/antraft.egg-info/top_level.txt +1 -0
- antraft-0.1.0/pyproject.toml +34 -0
- antraft-0.1.0/setup.cfg +4 -0
- antraft-0.1.0/tests/test_gateway.py +0 -0
- antraft-0.1.0/tests/test_policy_engine.py +0 -0
- antraft-0.1.0/tests/test_runtime.py +0 -0
antraft-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ashraf Galib Shaik
|
|
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.
|
antraft-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: antraft
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Policy-enforced runtime for autonomous AI agents
|
|
5
|
+
Author: Ashraf Galib Shaik
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Ashraf Galib Shaik
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/AshrafGalibShaik/ANTRAFT
|
|
29
|
+
Project-URL: Bug Tracker, https://github.com/AshrafGalibShaik/ANTRAFT/issues
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
34
|
+
Classifier: Topic :: System :: Operating System
|
|
35
|
+
Requires-Python: >=3.10
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
License-File: LICENSE
|
|
38
|
+
Requires-Dist: fastapi>=0.68.0
|
|
39
|
+
Requires-Dist: uvicorn>=0.15.0
|
|
40
|
+
Requires-Dist: typer>=0.4.0
|
|
41
|
+
Requires-Dist: requests>=2.26.0
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# ANTRAFT
|
|
45
|
+
|
|
46
|
+
**Policy-enforced runtime for autonomous AI agents.**
|
|
47
|
+
|
|
48
|
+
Antraft is a secure runtime environment designed to execute autonomous AI agents with strict, policy-based governance. It ensures that agents operate within defined boundaries, enforcing explicit allow/deny rules, resource limits, and comprehensive audit logging.
|
|
49
|
+
|
|
50
|
+
Unlike standard agent frameworks that prioritize capability, Antraft prioritizes **control and safety**.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Key Features
|
|
55
|
+
|
|
56
|
+
* **Policy Enforcement**: Every action proposed by an agent is evaluated against a strict policy before execution.
|
|
57
|
+
* **Secure by Default**: Actions are denied by default unless explicitly allowed.
|
|
58
|
+
* **Hard & Soft Limits**: Enforce maximum action checks (Hard/DENY) and runtime duration (Soft/PAUSE).
|
|
59
|
+
* **Immutable Audit Logs**: All agent decisions and runtime enforcements are recorded in an append-only audit log.
|
|
60
|
+
* **Tool Gateway**: A controlled interface for external tool execution, preventing unauthorized access.
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
Requires Python 3.10+.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Clone the repository
|
|
68
|
+
git clone https://github.com/AshrafGalibShaik/ANTRAFT.git
|
|
69
|
+
cd ANTRAFT
|
|
70
|
+
|
|
71
|
+
# Install dependencies
|
|
72
|
+
pip install .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
Here is a simple example of how to run an agent within the Antraft runtime.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from antraft.core.runtime import antraftRuntime
|
|
81
|
+
from antraft.core.agent import SimpleAgent
|
|
82
|
+
from antraft.policy.engine import PolicyEngine
|
|
83
|
+
from antraft.gateway.gateway import ToolGateway
|
|
84
|
+
|
|
85
|
+
# 1. Define the Policy
|
|
86
|
+
policy = {
|
|
87
|
+
"allow": ["run_tests", "read_file"],
|
|
88
|
+
"deny": ["shell_execute", "delete_file"],
|
|
89
|
+
"limits": {
|
|
90
|
+
"hard": {"max_actions": 10}, # Kill agent if exceeded
|
|
91
|
+
"soft": {"max_runtime_seconds": 60} # Pause agent if exceeded
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# 2. Setup the Components
|
|
96
|
+
agent = SimpleAgent()
|
|
97
|
+
engine = PolicyEngine(policy)
|
|
98
|
+
gateway = ToolGateway(tools={
|
|
99
|
+
"run_tests": lambda: print("Running tests..."),
|
|
100
|
+
"read_file": lambda path: print(f"Reading {path}...")
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
# 3. Initialize Runtime
|
|
104
|
+
runtime = antraftRuntime(
|
|
105
|
+
agent=agent,
|
|
106
|
+
policy_engine=engine,
|
|
107
|
+
tool_gateway=gateway
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# 4. Execute
|
|
111
|
+
runtime.run()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Architecture
|
|
115
|
+
|
|
116
|
+
Antraft operates on a rigorous cycle: **Propose > Evaluate > Enforce > Execute**.
|
|
117
|
+
|
|
118
|
+
1. **Agent**: Proposes an `Action` (e.g., "delete file").
|
|
119
|
+
2. **PolicyEngine**: The proposed action is passed to the Policy Engine, which evaluates it against the loaded ruleset. Evaluation fails fast and moves in a strict order:
|
|
120
|
+
1. **Explicit Deny**: Checks if the action is in the `deny` list. If found, returns `DENY`.
|
|
121
|
+
2. **Hard Limits**: Checks if global counters (e.g., `max_actions`) have been exceeded. If so, returns `DENY`.
|
|
122
|
+
3. **Soft Limits**: Checks if soft thresholds (e.g., `max_runtime_seconds`) have been exceeded. If so, returns `PAUSE`.
|
|
123
|
+
4. **Explicit Allow**: Checks if the action is in the `allow` list. If found, returns `ALLOW`.
|
|
124
|
+
5. **Default Deny**: If no rules match, the action is denied by default for security.
|
|
125
|
+
3. **AuditLogger**: The `AuditEvent` is constructed, capturing the Agent ID, proposed Action, Decision (ALLOW/DENY/PAUSE), and the Reason. This is written to an append-only log file.
|
|
126
|
+
4. **Runtime**: Enforces the decision:
|
|
127
|
+
* **ALLOW**: The action is passed to the `ToolGateway` for actual execution. The result is observed by the Agent.
|
|
128
|
+
* **DENY**: The runtime immediately terminates the agent loop (`context.kill()`).
|
|
129
|
+
* **PAUSE**: The runtime suspends the agent loop safely (`context.pause()`).
|
|
130
|
+
|
|
131
|
+
## Policy Configuration
|
|
132
|
+
|
|
133
|
+
Policies are defined as Python dictionaries or JSON objects. They dictate the exact boundaries of the agent's capabilities.
|
|
134
|
+
|
|
135
|
+
### Example Configuration
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"allow": [
|
|
140
|
+
"list_dir",
|
|
141
|
+
"read_file",
|
|
142
|
+
"analyze_code"
|
|
143
|
+
],
|
|
144
|
+
"deny": [
|
|
145
|
+
"connect_internet",
|
|
146
|
+
"exec_subprocess",
|
|
147
|
+
"write_file"
|
|
148
|
+
],
|
|
149
|
+
"limits": {
|
|
150
|
+
"hard": {
|
|
151
|
+
"max_actions": 50
|
|
152
|
+
},
|
|
153
|
+
"soft": {
|
|
154
|
+
"max_runtime_seconds": 300
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Limit Types
|
|
161
|
+
|
|
162
|
+
* **Hard Limits**: These define the absolute maximums for an execution session. If a hard limit is breached, the agent is considered compromised or malfunctioning, and the runtime will `DENY` further actions and terminate.
|
|
163
|
+
* **Soft Limits**: These define safe operating thresholds. If a soft limit is reached, the runtime will `PAUSE` execution. This allows for state inspection or manual intervention without killing the agent process entirely.
|
|
164
|
+
|
|
165
|
+
## API Reference
|
|
166
|
+
|
|
167
|
+
### antraft.core.runtime.antraftRuntime
|
|
168
|
+
|
|
169
|
+
The main entry point for executing an agent.
|
|
170
|
+
|
|
171
|
+
* `__init__(agent, policy_engine, tool_gateway, auditor=None)`: Initializes the runtime components.
|
|
172
|
+
* `run() -> RuntimeContext`: Starts the main execution loop. It continues until the agent finishes or a policy decision stops it.
|
|
173
|
+
|
|
174
|
+
### antraft.policy.engine.PolicyEngine
|
|
175
|
+
|
|
176
|
+
Stateless evaluator of actions.
|
|
177
|
+
|
|
178
|
+
* `evaluate(action, context) -> PolicyDecision`: Takes a proposed action and current runtime statistics (action count, runtime duration) and returns an enforcement decision.
|
|
179
|
+
|
|
180
|
+
### antraft.gateway.gateway.ToolGateway
|
|
181
|
+
|
|
182
|
+
The security boundary for external tools.
|
|
183
|
+
|
|
184
|
+
* `execute(action) -> Any`: Executes the verified action. This method is only called *after* the PolicyEngine has returned `ALLOW`.
|
|
185
|
+
|
|
186
|
+
## Contributing
|
|
187
|
+
|
|
188
|
+
Contributions are welcome. Please feel free to submit a Pull Request.
|
|
189
|
+
|
|
190
|
+
1. Fork the Project
|
|
191
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
192
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
|
193
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
194
|
+
5. Open a Pull Request
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
antraft-0.1.0/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# ANTRAFT
|
|
2
|
+
|
|
3
|
+
**Policy-enforced runtime for autonomous AI agents.**
|
|
4
|
+
|
|
5
|
+
Antraft is a secure runtime environment designed to execute autonomous AI agents with strict, policy-based governance. It ensures that agents operate within defined boundaries, enforcing explicit allow/deny rules, resource limits, and comprehensive audit logging.
|
|
6
|
+
|
|
7
|
+
Unlike standard agent frameworks that prioritize capability, Antraft prioritizes **control and safety**.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Key Features
|
|
12
|
+
|
|
13
|
+
* **Policy Enforcement**: Every action proposed by an agent is evaluated against a strict policy before execution.
|
|
14
|
+
* **Secure by Default**: Actions are denied by default unless explicitly allowed.
|
|
15
|
+
* **Hard & Soft Limits**: Enforce maximum action checks (Hard/DENY) and runtime duration (Soft/PAUSE).
|
|
16
|
+
* **Immutable Audit Logs**: All agent decisions and runtime enforcements are recorded in an append-only audit log.
|
|
17
|
+
* **Tool Gateway**: A controlled interface for external tool execution, preventing unauthorized access.
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Requires Python 3.10+.
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Clone the repository
|
|
25
|
+
git clone https://github.com/AshrafGalibShaik/ANTRAFT.git
|
|
26
|
+
cd ANTRAFT
|
|
27
|
+
|
|
28
|
+
# Install dependencies
|
|
29
|
+
pip install .
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
Here is a simple example of how to run an agent within the Antraft runtime.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from antraft.core.runtime import antraftRuntime
|
|
38
|
+
from antraft.core.agent import SimpleAgent
|
|
39
|
+
from antraft.policy.engine import PolicyEngine
|
|
40
|
+
from antraft.gateway.gateway import ToolGateway
|
|
41
|
+
|
|
42
|
+
# 1. Define the Policy
|
|
43
|
+
policy = {
|
|
44
|
+
"allow": ["run_tests", "read_file"],
|
|
45
|
+
"deny": ["shell_execute", "delete_file"],
|
|
46
|
+
"limits": {
|
|
47
|
+
"hard": {"max_actions": 10}, # Kill agent if exceeded
|
|
48
|
+
"soft": {"max_runtime_seconds": 60} # Pause agent if exceeded
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
# 2. Setup the Components
|
|
53
|
+
agent = SimpleAgent()
|
|
54
|
+
engine = PolicyEngine(policy)
|
|
55
|
+
gateway = ToolGateway(tools={
|
|
56
|
+
"run_tests": lambda: print("Running tests..."),
|
|
57
|
+
"read_file": lambda path: print(f"Reading {path}...")
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
# 3. Initialize Runtime
|
|
61
|
+
runtime = antraftRuntime(
|
|
62
|
+
agent=agent,
|
|
63
|
+
policy_engine=engine,
|
|
64
|
+
tool_gateway=gateway
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# 4. Execute
|
|
68
|
+
runtime.run()
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Architecture
|
|
72
|
+
|
|
73
|
+
Antraft operates on a rigorous cycle: **Propose > Evaluate > Enforce > Execute**.
|
|
74
|
+
|
|
75
|
+
1. **Agent**: Proposes an `Action` (e.g., "delete file").
|
|
76
|
+
2. **PolicyEngine**: The proposed action is passed to the Policy Engine, which evaluates it against the loaded ruleset. Evaluation fails fast and moves in a strict order:
|
|
77
|
+
1. **Explicit Deny**: Checks if the action is in the `deny` list. If found, returns `DENY`.
|
|
78
|
+
2. **Hard Limits**: Checks if global counters (e.g., `max_actions`) have been exceeded. If so, returns `DENY`.
|
|
79
|
+
3. **Soft Limits**: Checks if soft thresholds (e.g., `max_runtime_seconds`) have been exceeded. If so, returns `PAUSE`.
|
|
80
|
+
4. **Explicit Allow**: Checks if the action is in the `allow` list. If found, returns `ALLOW`.
|
|
81
|
+
5. **Default Deny**: If no rules match, the action is denied by default for security.
|
|
82
|
+
3. **AuditLogger**: The `AuditEvent` is constructed, capturing the Agent ID, proposed Action, Decision (ALLOW/DENY/PAUSE), and the Reason. This is written to an append-only log file.
|
|
83
|
+
4. **Runtime**: Enforces the decision:
|
|
84
|
+
* **ALLOW**: The action is passed to the `ToolGateway` for actual execution. The result is observed by the Agent.
|
|
85
|
+
* **DENY**: The runtime immediately terminates the agent loop (`context.kill()`).
|
|
86
|
+
* **PAUSE**: The runtime suspends the agent loop safely (`context.pause()`).
|
|
87
|
+
|
|
88
|
+
## Policy Configuration
|
|
89
|
+
|
|
90
|
+
Policies are defined as Python dictionaries or JSON objects. They dictate the exact boundaries of the agent's capabilities.
|
|
91
|
+
|
|
92
|
+
### Example Configuration
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"allow": [
|
|
97
|
+
"list_dir",
|
|
98
|
+
"read_file",
|
|
99
|
+
"analyze_code"
|
|
100
|
+
],
|
|
101
|
+
"deny": [
|
|
102
|
+
"connect_internet",
|
|
103
|
+
"exec_subprocess",
|
|
104
|
+
"write_file"
|
|
105
|
+
],
|
|
106
|
+
"limits": {
|
|
107
|
+
"hard": {
|
|
108
|
+
"max_actions": 50
|
|
109
|
+
},
|
|
110
|
+
"soft": {
|
|
111
|
+
"max_runtime_seconds": 300
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Limit Types
|
|
118
|
+
|
|
119
|
+
* **Hard Limits**: These define the absolute maximums for an execution session. If a hard limit is breached, the agent is considered compromised or malfunctioning, and the runtime will `DENY` further actions and terminate.
|
|
120
|
+
* **Soft Limits**: These define safe operating thresholds. If a soft limit is reached, the runtime will `PAUSE` execution. This allows for state inspection or manual intervention without killing the agent process entirely.
|
|
121
|
+
|
|
122
|
+
## API Reference
|
|
123
|
+
|
|
124
|
+
### antraft.core.runtime.antraftRuntime
|
|
125
|
+
|
|
126
|
+
The main entry point for executing an agent.
|
|
127
|
+
|
|
128
|
+
* `__init__(agent, policy_engine, tool_gateway, auditor=None)`: Initializes the runtime components.
|
|
129
|
+
* `run() -> RuntimeContext`: Starts the main execution loop. It continues until the agent finishes or a policy decision stops it.
|
|
130
|
+
|
|
131
|
+
### antraft.policy.engine.PolicyEngine
|
|
132
|
+
|
|
133
|
+
Stateless evaluator of actions.
|
|
134
|
+
|
|
135
|
+
* `evaluate(action, context) -> PolicyDecision`: Takes a proposed action and current runtime statistics (action count, runtime duration) and returns an enforcement decision.
|
|
136
|
+
|
|
137
|
+
### antraft.gateway.gateway.ToolGateway
|
|
138
|
+
|
|
139
|
+
The security boundary for external tools.
|
|
140
|
+
|
|
141
|
+
* `execute(action) -> Any`: Executes the verified action. This method is only called *after* the PolicyEngine has returned `ALLOW`.
|
|
142
|
+
|
|
143
|
+
## Contributing
|
|
144
|
+
|
|
145
|
+
Contributions are welcome. Please feel free to submit a Pull Request.
|
|
146
|
+
|
|
147
|
+
1. Fork the Project
|
|
148
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
149
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
|
150
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
151
|
+
5. Open a Pull Request
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
|
File without changes
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: antraft
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Policy-enforced runtime for autonomous AI agents
|
|
5
|
+
Author: Ashraf Galib Shaik
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Ashraf Galib Shaik
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/AshrafGalibShaik/ANTRAFT
|
|
29
|
+
Project-URL: Bug Tracker, https://github.com/AshrafGalibShaik/ANTRAFT/issues
|
|
30
|
+
Classifier: Programming Language :: Python :: 3
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
34
|
+
Classifier: Topic :: System :: Operating System
|
|
35
|
+
Requires-Python: >=3.10
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
License-File: LICENSE
|
|
38
|
+
Requires-Dist: fastapi>=0.68.0
|
|
39
|
+
Requires-Dist: uvicorn>=0.15.0
|
|
40
|
+
Requires-Dist: typer>=0.4.0
|
|
41
|
+
Requires-Dist: requests>=2.26.0
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# ANTRAFT
|
|
45
|
+
|
|
46
|
+
**Policy-enforced runtime for autonomous AI agents.**
|
|
47
|
+
|
|
48
|
+
Antraft is a secure runtime environment designed to execute autonomous AI agents with strict, policy-based governance. It ensures that agents operate within defined boundaries, enforcing explicit allow/deny rules, resource limits, and comprehensive audit logging.
|
|
49
|
+
|
|
50
|
+
Unlike standard agent frameworks that prioritize capability, Antraft prioritizes **control and safety**.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Key Features
|
|
55
|
+
|
|
56
|
+
* **Policy Enforcement**: Every action proposed by an agent is evaluated against a strict policy before execution.
|
|
57
|
+
* **Secure by Default**: Actions are denied by default unless explicitly allowed.
|
|
58
|
+
* **Hard & Soft Limits**: Enforce maximum action checks (Hard/DENY) and runtime duration (Soft/PAUSE).
|
|
59
|
+
* **Immutable Audit Logs**: All agent decisions and runtime enforcements are recorded in an append-only audit log.
|
|
60
|
+
* **Tool Gateway**: A controlled interface for external tool execution, preventing unauthorized access.
|
|
61
|
+
|
|
62
|
+
## Installation
|
|
63
|
+
|
|
64
|
+
Requires Python 3.10+.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Clone the repository
|
|
68
|
+
git clone https://github.com/AshrafGalibShaik/ANTRAFT.git
|
|
69
|
+
cd ANTRAFT
|
|
70
|
+
|
|
71
|
+
# Install dependencies
|
|
72
|
+
pip install .
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
Here is a simple example of how to run an agent within the Antraft runtime.
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from antraft.core.runtime import antraftRuntime
|
|
81
|
+
from antraft.core.agent import SimpleAgent
|
|
82
|
+
from antraft.policy.engine import PolicyEngine
|
|
83
|
+
from antraft.gateway.gateway import ToolGateway
|
|
84
|
+
|
|
85
|
+
# 1. Define the Policy
|
|
86
|
+
policy = {
|
|
87
|
+
"allow": ["run_tests", "read_file"],
|
|
88
|
+
"deny": ["shell_execute", "delete_file"],
|
|
89
|
+
"limits": {
|
|
90
|
+
"hard": {"max_actions": 10}, # Kill agent if exceeded
|
|
91
|
+
"soft": {"max_runtime_seconds": 60} # Pause agent if exceeded
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# 2. Setup the Components
|
|
96
|
+
agent = SimpleAgent()
|
|
97
|
+
engine = PolicyEngine(policy)
|
|
98
|
+
gateway = ToolGateway(tools={
|
|
99
|
+
"run_tests": lambda: print("Running tests..."),
|
|
100
|
+
"read_file": lambda path: print(f"Reading {path}...")
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
# 3. Initialize Runtime
|
|
104
|
+
runtime = antraftRuntime(
|
|
105
|
+
agent=agent,
|
|
106
|
+
policy_engine=engine,
|
|
107
|
+
tool_gateway=gateway
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# 4. Execute
|
|
111
|
+
runtime.run()
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Architecture
|
|
115
|
+
|
|
116
|
+
Antraft operates on a rigorous cycle: **Propose > Evaluate > Enforce > Execute**.
|
|
117
|
+
|
|
118
|
+
1. **Agent**: Proposes an `Action` (e.g., "delete file").
|
|
119
|
+
2. **PolicyEngine**: The proposed action is passed to the Policy Engine, which evaluates it against the loaded ruleset. Evaluation fails fast and moves in a strict order:
|
|
120
|
+
1. **Explicit Deny**: Checks if the action is in the `deny` list. If found, returns `DENY`.
|
|
121
|
+
2. **Hard Limits**: Checks if global counters (e.g., `max_actions`) have been exceeded. If so, returns `DENY`.
|
|
122
|
+
3. **Soft Limits**: Checks if soft thresholds (e.g., `max_runtime_seconds`) have been exceeded. If so, returns `PAUSE`.
|
|
123
|
+
4. **Explicit Allow**: Checks if the action is in the `allow` list. If found, returns `ALLOW`.
|
|
124
|
+
5. **Default Deny**: If no rules match, the action is denied by default for security.
|
|
125
|
+
3. **AuditLogger**: The `AuditEvent` is constructed, capturing the Agent ID, proposed Action, Decision (ALLOW/DENY/PAUSE), and the Reason. This is written to an append-only log file.
|
|
126
|
+
4. **Runtime**: Enforces the decision:
|
|
127
|
+
* **ALLOW**: The action is passed to the `ToolGateway` for actual execution. The result is observed by the Agent.
|
|
128
|
+
* **DENY**: The runtime immediately terminates the agent loop (`context.kill()`).
|
|
129
|
+
* **PAUSE**: The runtime suspends the agent loop safely (`context.pause()`).
|
|
130
|
+
|
|
131
|
+
## Policy Configuration
|
|
132
|
+
|
|
133
|
+
Policies are defined as Python dictionaries or JSON objects. They dictate the exact boundaries of the agent's capabilities.
|
|
134
|
+
|
|
135
|
+
### Example Configuration
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"allow": [
|
|
140
|
+
"list_dir",
|
|
141
|
+
"read_file",
|
|
142
|
+
"analyze_code"
|
|
143
|
+
],
|
|
144
|
+
"deny": [
|
|
145
|
+
"connect_internet",
|
|
146
|
+
"exec_subprocess",
|
|
147
|
+
"write_file"
|
|
148
|
+
],
|
|
149
|
+
"limits": {
|
|
150
|
+
"hard": {
|
|
151
|
+
"max_actions": 50
|
|
152
|
+
},
|
|
153
|
+
"soft": {
|
|
154
|
+
"max_runtime_seconds": 300
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Limit Types
|
|
161
|
+
|
|
162
|
+
* **Hard Limits**: These define the absolute maximums for an execution session. If a hard limit is breached, the agent is considered compromised or malfunctioning, and the runtime will `DENY` further actions and terminate.
|
|
163
|
+
* **Soft Limits**: These define safe operating thresholds. If a soft limit is reached, the runtime will `PAUSE` execution. This allows for state inspection or manual intervention without killing the agent process entirely.
|
|
164
|
+
|
|
165
|
+
## API Reference
|
|
166
|
+
|
|
167
|
+
### antraft.core.runtime.antraftRuntime
|
|
168
|
+
|
|
169
|
+
The main entry point for executing an agent.
|
|
170
|
+
|
|
171
|
+
* `__init__(agent, policy_engine, tool_gateway, auditor=None)`: Initializes the runtime components.
|
|
172
|
+
* `run() -> RuntimeContext`: Starts the main execution loop. It continues until the agent finishes or a policy decision stops it.
|
|
173
|
+
|
|
174
|
+
### antraft.policy.engine.PolicyEngine
|
|
175
|
+
|
|
176
|
+
Stateless evaluator of actions.
|
|
177
|
+
|
|
178
|
+
* `evaluate(action, context) -> PolicyDecision`: Takes a proposed action and current runtime statistics (action count, runtime duration) and returns an enforcement decision.
|
|
179
|
+
|
|
180
|
+
### antraft.gateway.gateway.ToolGateway
|
|
181
|
+
|
|
182
|
+
The security boundary for external tools.
|
|
183
|
+
|
|
184
|
+
* `execute(action) -> Any`: Executes the verified action. This method is only called *after* the PolicyEngine has returned `ALLOW`.
|
|
185
|
+
|
|
186
|
+
## Contributing
|
|
187
|
+
|
|
188
|
+
Contributions are welcome. Please feel free to submit a Pull Request.
|
|
189
|
+
|
|
190
|
+
1. Fork the Project
|
|
191
|
+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
|
|
192
|
+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
|
|
193
|
+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
|
|
194
|
+
5. Open a Pull Request
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
antraft/__init__.py
|
|
5
|
+
antraft.egg-info/PKG-INFO
|
|
6
|
+
antraft.egg-info/SOURCES.txt
|
|
7
|
+
antraft.egg-info/dependency_links.txt
|
|
8
|
+
antraft.egg-info/requires.txt
|
|
9
|
+
antraft.egg-info/top_level.txt
|
|
10
|
+
tests/test_gateway.py
|
|
11
|
+
tests/test_policy_engine.py
|
|
12
|
+
tests/test_runtime.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
antraft
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "antraft"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Policy-enforced runtime for autonomous AI agents"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
authors = [
|
|
12
|
+
{ name = "Ashraf Galib Shaik" }
|
|
13
|
+
]
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
20
|
+
"Topic :: System :: Operating System",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"fastapi>=0.68.0",
|
|
24
|
+
"uvicorn>=0.15.0",
|
|
25
|
+
"typer>=0.4.0",
|
|
26
|
+
"requests>=2.26.0"
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
"Homepage" = "https://github.com/AshrafGalibShaik/ANTRAFT"
|
|
31
|
+
"Bug Tracker" = "https://github.com/AshrafGalibShaik/ANTRAFT/issues"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
packages = ["antraft"]
|
antraft-0.1.0/setup.cfg
ADDED
|
File without changes
|
|
File without changes
|
|
File without changes
|