genesis-blackbox 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.
- genesis_blackbox-0.1.0/LICENSE +21 -0
- genesis_blackbox-0.1.0/PKG-INFO +256 -0
- genesis_blackbox-0.1.0/README.md +227 -0
- genesis_blackbox-0.1.0/blackbox/__init__.py +39 -0
- genesis_blackbox-0.1.0/blackbox/ast_engine/__init__.py +3 -0
- genesis_blackbox-0.1.0/blackbox/ast_engine/graph.py +155 -0
- genesis_blackbox-0.1.0/blackbox/cli.py +156 -0
- genesis_blackbox-0.1.0/blackbox/compiler/__init__.py +3 -0
- genesis_blackbox-0.1.0/blackbox/compiler/autopsy.py +301 -0
- genesis_blackbox-0.1.0/blackbox/instrumentation.py +90 -0
- genesis_blackbox-0.1.0/blackbox/mcp_server.py +229 -0
- genesis_blackbox-0.1.0/blackbox/recorder/__init__.py +35 -0
- genesis_blackbox-0.1.0/blackbox/recorder/exception_hook.py +253 -0
- genesis_blackbox-0.1.0/blackbox/recorder/http_interceptor.py +354 -0
- genesis_blackbox-0.1.0/blackbox/recorder/process_hook.py +322 -0
- genesis_blackbox-0.1.0/blackbox/recorder/runner.py +67 -0
- genesis_blackbox-0.1.0/blackbox/recorder/sql_interceptor.py +264 -0
- genesis_blackbox-0.1.0/blackbox/recorder/wal_ring.py +229 -0
- genesis_blackbox-0.1.0/blackbox/ui/__init__.py +7 -0
- genesis_blackbox-0.1.0/blackbox/ui/server.py +475 -0
- genesis_blackbox-0.1.0/genesis_blackbox.egg-info/PKG-INFO +256 -0
- genesis_blackbox-0.1.0/genesis_blackbox.egg-info/SOURCES.txt +33 -0
- genesis_blackbox-0.1.0/genesis_blackbox.egg-info/dependency_links.txt +1 -0
- genesis_blackbox-0.1.0/genesis_blackbox.egg-info/entry_points.txt +3 -0
- genesis_blackbox-0.1.0/genesis_blackbox.egg-info/requires.txt +4 -0
- genesis_blackbox-0.1.0/genesis_blackbox.egg-info/top_level.txt +1 -0
- genesis_blackbox-0.1.0/pyproject.toml +39 -0
- genesis_blackbox-0.1.0/setup.cfg +4 -0
- genesis_blackbox-0.1.0/tests/test_compiler_and_ast.py +70 -0
- genesis_blackbox-0.1.0/tests/test_exception_hook.py +88 -0
- genesis_blackbox-0.1.0/tests/test_interceptors.py +240 -0
- genesis_blackbox-0.1.0/tests/test_phase3_compiler_cli_mcp.py +198 -0
- genesis_blackbox-0.1.0/tests/test_phase4_ui_and_dogfood.py +118 -0
- genesis_blackbox-0.1.0/tests/test_phase6_instrumentation.py +216 -0
- genesis_blackbox-0.1.0/tests/test_wal_ring.py +87 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Johann Schiffer / Project Genesis
|
|
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,256 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: genesis-blackbox
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Deterministic Runtime Flight Recorder & AST Blast-Radius Causal Crash Compiler for AI-Assisted Software Engineering
|
|
5
|
+
Author: Johann Schiffer
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://johannschiffer.github.io
|
|
8
|
+
Project-URL: Repository, https://github.com/johannschiffer/genesis-blackbox
|
|
9
|
+
Project-URL: Support / Donate, https://ko-fi.com/johannschiffer
|
|
10
|
+
Keywords: mcp,debugging,ast,flight-recorder,ai-agents,sqlite-wal
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: Software Development :: Debuggers
|
|
21
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
27
|
+
Requires-Dist: pytest-asyncio>=0.20.0; extra == "dev"
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
|
|
30
|
+
# Genesis Blackbox
|
|
31
|
+
|
|
32
|
+
[](https://www.python.org/downloads/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
[](https://ko-fi.com/johannschiffer)
|
|
35
|
+
|
|
36
|
+
Deterministic Runtime Flight Recorder and AST Blast-Radius Causal Crash Compiler for AI-assisted engineering and autonomous coding agents.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Overview
|
|
41
|
+
|
|
42
|
+
When coding agents (Claude, Cursor, Windsurf) encounter runtime crashes, standard stack traces leave them guessing. They lack the execution history leading up to the error, the local variable state across stack frames, and the static dependency blast radius.
|
|
43
|
+
|
|
44
|
+
**Genesis Blackbox** captures execution context with sub-millisecond overhead:
|
|
45
|
+
1. **SQLite WAL Ring-Buffer (`wal_ring.py`):** Circular bounded log for HTTP requests, SQL queries with sanitized parameters, and subprocess activity.
|
|
46
|
+
2. **Deep Exception Serializer (`exception_hook.py`):** Automatically captures local variables per frame at crash time with circular-reference safety and credential redaction.
|
|
47
|
+
3. **AST Blast-Radius Engine (`ast_engine/`):** Static call-graph analyzer that maps upstream callers and downstream callee dependencies.
|
|
48
|
+
4. **Causal Crash Compiler (`compiler/`):** Synthesizes timeline events, frame variables, and AST blast radius into a self-contained `.blackbox.md` Autopsy Capsule.
|
|
49
|
+
5. **Native MCP Server (`mcp_server.py`):** Direct Model Context Protocol interface exposing timeline queries, crash autopsies, and blast-radius tools over stdio.
|
|
50
|
+
6. **Embedded Visual Timeline (`ui/`):** Lightweight local web inspector for timeline events and crash autopsies.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Architecture
|
|
55
|
+
|
|
56
|
+
```mermaid
|
|
57
|
+
flowchart LR
|
|
58
|
+
subgraph Runtime ["Runtime Interceptors"]
|
|
59
|
+
HTTP["HTTP (ASGI / WSGI)"]
|
|
60
|
+
SQL["SQL (sqlite3 / DBAPI)"]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
WAL[("SQLite WAL Ring-Buffer<br/>(Sub-ms Circular Store)")]
|
|
64
|
+
AST["AST Blast-Radius Engine<br/>(Static Call Graph)"]
|
|
65
|
+
Compiler["Causal Crash Compiler"]
|
|
66
|
+
Capsule[(".blackbox.md<br/>Autopsy Capsule")]
|
|
67
|
+
AIAgent["AI Agent 1-Shot Fix<br/>(Claude, Cursor, Windsurf)"]
|
|
68
|
+
|
|
69
|
+
HTTP --> WAL
|
|
70
|
+
SQL --> WAL
|
|
71
|
+
WAL --> Compiler
|
|
72
|
+
AST --> Compiler
|
|
73
|
+
Compiler --> Capsule
|
|
74
|
+
Capsule --> AIAgent
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
+-------------------------------------------------+
|
|
79
|
+
| Runtime Interceptors |
|
|
80
|
+
| ASGI / WSGI Middleware & SQL Drivers |
|
|
81
|
+
+------------------------+------------------------+
|
|
82
|
+
|
|
|
83
|
+
v
|
|
84
|
+
+-------------------------------------------------+
|
|
85
|
+
| SQLite WAL Ring-Buffer |
|
|
86
|
+
| (Sub-ms Overhead, Circular Pruning) |
|
|
87
|
+
+------------------------+------------------------+
|
|
88
|
+
| +-----------------------------+
|
|
89
|
+
| | AST Blast-Radius Engine |
|
|
90
|
+
| | (Static Call Graph Nodes) |
|
|
91
|
+
+--------+---------+--------------+--------------+
|
|
92
|
+
| |
|
|
93
|
+
v v
|
|
94
|
+
+------------------------------------------------+
|
|
95
|
+
| Causal Crash Compiler |
|
|
96
|
+
+------------------------+-----------------------+
|
|
97
|
+
|
|
|
98
|
+
v
|
|
99
|
+
+------------------------------------------------+
|
|
100
|
+
| .blackbox.md Capsule |
|
|
101
|
+
| (Timeline + Frame State + Blast Radius) |
|
|
102
|
+
+------------------------+-----------------------+
|
|
103
|
+
|
|
|
104
|
+
v
|
|
105
|
+
+------------------------------------------------+
|
|
106
|
+
| AI Agent 1-Shot Deterministic Fix |
|
|
107
|
+
| (Claude, Cursor, Windsurf) |
|
|
108
|
+
+------------------------------------------------+
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Quickstart
|
|
114
|
+
|
|
115
|
+
### 1. Installation
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
pip install genesis-blackbox
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
For development dependencies (pytest, pytest-asyncio, build, twine):
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pip install genesis-blackbox[dev]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### 2. Frictionless Recording
|
|
128
|
+
|
|
129
|
+
Execute any Python entrypoint or microservice under the flight recorder wrapper:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
blackbox record -- python app.py
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The flight recorder automatically:
|
|
136
|
+
- Initializes a local bounded SQLite WAL ring buffer at `.blackbox/wal.sqlite`.
|
|
137
|
+
- Hooks `sys.excepthook` and `threading.excepthook` for deep variable serialization upon crash.
|
|
138
|
+
- Redacts sensitive headers (Authorization, Cookie, API keys) and SQL credentials.
|
|
139
|
+
|
|
140
|
+
You can also record custom events directly from the CLI or your code:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
blackbox record --type HTTP_REQ --payload '{"path": "/api/users", "status": 500, "error": "DatabaseTimeout"}'
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 3. Visual Inspection
|
|
147
|
+
|
|
148
|
+
Launch the embedded local web inspector to explore recent events, execution timelines, and crash autopsy capsules:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
blackbox ui --port 8765
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Navigate to `http://127.0.0.1:8765` in your browser.
|
|
155
|
+
|
|
156
|
+
### 4. Causal Autopsy Generation
|
|
157
|
+
|
|
158
|
+
Generate a complete Markdown autopsy document from the latest recorded crash:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
blackbox autopsy
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
This compiles `.blackbox.md` in the current directory with:
|
|
165
|
+
- Target exception class, message, and formatted traceback.
|
|
166
|
+
- Local variables across each stack frame.
|
|
167
|
+
- Recent execution timeline leading to the crash.
|
|
168
|
+
- AST blast-radius analysis showing impacted callers and callees.
|
|
169
|
+
|
|
170
|
+
To inspect the recent execution timeline via CLI:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
blackbox timeline --limit 20
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
To run a blast-radius calculation on a file or specific symbol:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
blackbox blast-radius app.py --symbol handle_request
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## MCP Server Configuration
|
|
185
|
+
|
|
186
|
+
Genesis Blackbox includes a native Model Context Protocol (MCP) server (`blackbox.mcp_server`) exposing diagnostic tools directly to AI coding agents.
|
|
187
|
+
|
|
188
|
+
Exposed MCP tools:
|
|
189
|
+
- `get_crash_autopsy`: Compiles `.blackbox.md` from recorded WAL events.
|
|
190
|
+
- `get_blast_radius`: Analyzes upstream and downstream code dependencies.
|
|
191
|
+
- `query_execution_timeline`: Queries recent HTTP, SQL, and exception events.
|
|
192
|
+
- `record_event`: Ingests custom execution events into the WAL ring buffer.
|
|
193
|
+
|
|
194
|
+
### Claude Desktop
|
|
195
|
+
|
|
196
|
+
Add to your `claude_desktop_config.json`:
|
|
197
|
+
|
|
198
|
+
```json
|
|
199
|
+
{
|
|
200
|
+
"mcpServers": {
|
|
201
|
+
"blackbox": {
|
|
202
|
+
"command": "python",
|
|
203
|
+
"args": ["-m", "blackbox.mcp_server"]
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Cursor
|
|
210
|
+
|
|
211
|
+
Add to your `.cursor/mcp.json`:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"mcpServers": {
|
|
216
|
+
"blackbox": {
|
|
217
|
+
"command": "python",
|
|
218
|
+
"args": ["-m", "blackbox.mcp_server"]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Windsurf
|
|
225
|
+
|
|
226
|
+
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"mcpServers": {
|
|
231
|
+
"blackbox": {
|
|
232
|
+
"command": "python",
|
|
233
|
+
"args": ["-m", "blackbox.mcp_server"]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## Support and Sponsorship
|
|
242
|
+
|
|
243
|
+
Genesis Blackbox is 100% free and open-source software under the MIT license.
|
|
244
|
+
|
|
245
|
+
If this tool accelerates your development or helps your AI agents resolve bugs deterministically, consider supporting ongoing development:
|
|
246
|
+
|
|
247
|
+
[](https://ko-fi.com/johannschiffer)
|
|
248
|
+
|
|
249
|
+
Support page: [https://ko-fi.com/johannschiffer](https://ko-fi.com/johannschiffer)
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
256
|
+
Copyright (c) Johann Schiffer.
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Genesis Blackbox
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://ko-fi.com/johannschiffer)
|
|
6
|
+
|
|
7
|
+
Deterministic Runtime Flight Recorder and AST Blast-Radius Causal Crash Compiler for AI-assisted engineering and autonomous coding agents.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
When coding agents (Claude, Cursor, Windsurf) encounter runtime crashes, standard stack traces leave them guessing. They lack the execution history leading up to the error, the local variable state across stack frames, and the static dependency blast radius.
|
|
14
|
+
|
|
15
|
+
**Genesis Blackbox** captures execution context with sub-millisecond overhead:
|
|
16
|
+
1. **SQLite WAL Ring-Buffer (`wal_ring.py`):** Circular bounded log for HTTP requests, SQL queries with sanitized parameters, and subprocess activity.
|
|
17
|
+
2. **Deep Exception Serializer (`exception_hook.py`):** Automatically captures local variables per frame at crash time with circular-reference safety and credential redaction.
|
|
18
|
+
3. **AST Blast-Radius Engine (`ast_engine/`):** Static call-graph analyzer that maps upstream callers and downstream callee dependencies.
|
|
19
|
+
4. **Causal Crash Compiler (`compiler/`):** Synthesizes timeline events, frame variables, and AST blast radius into a self-contained `.blackbox.md` Autopsy Capsule.
|
|
20
|
+
5. **Native MCP Server (`mcp_server.py`):** Direct Model Context Protocol interface exposing timeline queries, crash autopsies, and blast-radius tools over stdio.
|
|
21
|
+
6. **Embedded Visual Timeline (`ui/`):** Lightweight local web inspector for timeline events and crash autopsies.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Architecture
|
|
26
|
+
|
|
27
|
+
```mermaid
|
|
28
|
+
flowchart LR
|
|
29
|
+
subgraph Runtime ["Runtime Interceptors"]
|
|
30
|
+
HTTP["HTTP (ASGI / WSGI)"]
|
|
31
|
+
SQL["SQL (sqlite3 / DBAPI)"]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
WAL[("SQLite WAL Ring-Buffer<br/>(Sub-ms Circular Store)")]
|
|
35
|
+
AST["AST Blast-Radius Engine<br/>(Static Call Graph)"]
|
|
36
|
+
Compiler["Causal Crash Compiler"]
|
|
37
|
+
Capsule[(".blackbox.md<br/>Autopsy Capsule")]
|
|
38
|
+
AIAgent["AI Agent 1-Shot Fix<br/>(Claude, Cursor, Windsurf)"]
|
|
39
|
+
|
|
40
|
+
HTTP --> WAL
|
|
41
|
+
SQL --> WAL
|
|
42
|
+
WAL --> Compiler
|
|
43
|
+
AST --> Compiler
|
|
44
|
+
Compiler --> Capsule
|
|
45
|
+
Capsule --> AIAgent
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
+-------------------------------------------------+
|
|
50
|
+
| Runtime Interceptors |
|
|
51
|
+
| ASGI / WSGI Middleware & SQL Drivers |
|
|
52
|
+
+------------------------+------------------------+
|
|
53
|
+
|
|
|
54
|
+
v
|
|
55
|
+
+-------------------------------------------------+
|
|
56
|
+
| SQLite WAL Ring-Buffer |
|
|
57
|
+
| (Sub-ms Overhead, Circular Pruning) |
|
|
58
|
+
+------------------------+------------------------+
|
|
59
|
+
| +-----------------------------+
|
|
60
|
+
| | AST Blast-Radius Engine |
|
|
61
|
+
| | (Static Call Graph Nodes) |
|
|
62
|
+
+--------+---------+--------------+--------------+
|
|
63
|
+
| |
|
|
64
|
+
v v
|
|
65
|
+
+------------------------------------------------+
|
|
66
|
+
| Causal Crash Compiler |
|
|
67
|
+
+------------------------+-----------------------+
|
|
68
|
+
|
|
|
69
|
+
v
|
|
70
|
+
+------------------------------------------------+
|
|
71
|
+
| .blackbox.md Capsule |
|
|
72
|
+
| (Timeline + Frame State + Blast Radius) |
|
|
73
|
+
+------------------------+-----------------------+
|
|
74
|
+
|
|
|
75
|
+
v
|
|
76
|
+
+------------------------------------------------+
|
|
77
|
+
| AI Agent 1-Shot Deterministic Fix |
|
|
78
|
+
| (Claude, Cursor, Windsurf) |
|
|
79
|
+
+------------------------------------------------+
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Quickstart
|
|
85
|
+
|
|
86
|
+
### 1. Installation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install genesis-blackbox
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For development dependencies (pytest, pytest-asyncio, build, twine):
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
pip install genesis-blackbox[dev]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 2. Frictionless Recording
|
|
99
|
+
|
|
100
|
+
Execute any Python entrypoint or microservice under the flight recorder wrapper:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
blackbox record -- python app.py
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The flight recorder automatically:
|
|
107
|
+
- Initializes a local bounded SQLite WAL ring buffer at `.blackbox/wal.sqlite`.
|
|
108
|
+
- Hooks `sys.excepthook` and `threading.excepthook` for deep variable serialization upon crash.
|
|
109
|
+
- Redacts sensitive headers (Authorization, Cookie, API keys) and SQL credentials.
|
|
110
|
+
|
|
111
|
+
You can also record custom events directly from the CLI or your code:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
blackbox record --type HTTP_REQ --payload '{"path": "/api/users", "status": 500, "error": "DatabaseTimeout"}'
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 3. Visual Inspection
|
|
118
|
+
|
|
119
|
+
Launch the embedded local web inspector to explore recent events, execution timelines, and crash autopsy capsules:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
blackbox ui --port 8765
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Navigate to `http://127.0.0.1:8765` in your browser.
|
|
126
|
+
|
|
127
|
+
### 4. Causal Autopsy Generation
|
|
128
|
+
|
|
129
|
+
Generate a complete Markdown autopsy document from the latest recorded crash:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
blackbox autopsy
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
This compiles `.blackbox.md` in the current directory with:
|
|
136
|
+
- Target exception class, message, and formatted traceback.
|
|
137
|
+
- Local variables across each stack frame.
|
|
138
|
+
- Recent execution timeline leading to the crash.
|
|
139
|
+
- AST blast-radius analysis showing impacted callers and callees.
|
|
140
|
+
|
|
141
|
+
To inspect the recent execution timeline via CLI:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
blackbox timeline --limit 20
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
To run a blast-radius calculation on a file or specific symbol:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
blackbox blast-radius app.py --symbol handle_request
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## MCP Server Configuration
|
|
156
|
+
|
|
157
|
+
Genesis Blackbox includes a native Model Context Protocol (MCP) server (`blackbox.mcp_server`) exposing diagnostic tools directly to AI coding agents.
|
|
158
|
+
|
|
159
|
+
Exposed MCP tools:
|
|
160
|
+
- `get_crash_autopsy`: Compiles `.blackbox.md` from recorded WAL events.
|
|
161
|
+
- `get_blast_radius`: Analyzes upstream and downstream code dependencies.
|
|
162
|
+
- `query_execution_timeline`: Queries recent HTTP, SQL, and exception events.
|
|
163
|
+
- `record_event`: Ingests custom execution events into the WAL ring buffer.
|
|
164
|
+
|
|
165
|
+
### Claude Desktop
|
|
166
|
+
|
|
167
|
+
Add to your `claude_desktop_config.json`:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"mcpServers": {
|
|
172
|
+
"blackbox": {
|
|
173
|
+
"command": "python",
|
|
174
|
+
"args": ["-m", "blackbox.mcp_server"]
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Cursor
|
|
181
|
+
|
|
182
|
+
Add to your `.cursor/mcp.json`:
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"mcpServers": {
|
|
187
|
+
"blackbox": {
|
|
188
|
+
"command": "python",
|
|
189
|
+
"args": ["-m", "blackbox.mcp_server"]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Windsurf
|
|
196
|
+
|
|
197
|
+
Add to `~/.codeium/windsurf/mcp_config.json`:
|
|
198
|
+
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"mcpServers": {
|
|
202
|
+
"blackbox": {
|
|
203
|
+
"command": "python",
|
|
204
|
+
"args": ["-m", "blackbox.mcp_server"]
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Support and Sponsorship
|
|
213
|
+
|
|
214
|
+
Genesis Blackbox is 100% free and open-source software under the MIT license.
|
|
215
|
+
|
|
216
|
+
If this tool accelerates your development or helps your AI agents resolve bugs deterministically, consider supporting ongoing development:
|
|
217
|
+
|
|
218
|
+
[](https://ko-fi.com/johannschiffer)
|
|
219
|
+
|
|
220
|
+
Support page: [https://ko-fi.com/johannschiffer](https://ko-fi.com/johannschiffer)
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## License
|
|
225
|
+
|
|
226
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
227
|
+
Copyright (c) Johann Schiffer.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Genesis Blackbox: Flight Recorder & AST Blast-Radius Causal Crash Compiler.
|
|
3
|
+
100% Free & Open Source under the MIT License.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "0.1.0"
|
|
7
|
+
__author__ = "Johann Schiffer / Project Genesis"
|
|
8
|
+
__license__ = "MIT"
|
|
9
|
+
|
|
10
|
+
from .recorder.wal_ring import WalRingBuffer
|
|
11
|
+
from .recorder.exception_hook import ExceptionHook, SafeSerializer, install_exception_hook, uninstall_exception_hook
|
|
12
|
+
from .recorder.http_interceptor import BlackboxASGIMiddleware, BlackboxWSGIMiddleware, HttpTraceContext
|
|
13
|
+
from .recorder.sql_interceptor import TracedConnection, TracedCursor, SqlInterceptor, SqlTraceContext
|
|
14
|
+
from .recorder.process_hook import SubprocessInterceptor
|
|
15
|
+
from .instrumentation import auto_instrument
|
|
16
|
+
from .ast_engine.graph import CodebaseGraph
|
|
17
|
+
from .compiler.autopsy import CausalCrashCompiler
|
|
18
|
+
from .mcp_server import BlackboxMCPServer
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"WalRingBuffer",
|
|
22
|
+
"ExceptionHook",
|
|
23
|
+
"SafeSerializer",
|
|
24
|
+
"install_exception_hook",
|
|
25
|
+
"uninstall_exception_hook",
|
|
26
|
+
"BlackboxASGIMiddleware",
|
|
27
|
+
"BlackboxWSGIMiddleware",
|
|
28
|
+
"HttpTraceContext",
|
|
29
|
+
"TracedConnection",
|
|
30
|
+
"TracedCursor",
|
|
31
|
+
"SqlInterceptor",
|
|
32
|
+
"SqlTraceContext",
|
|
33
|
+
"SubprocessInterceptor",
|
|
34
|
+
"auto_instrument",
|
|
35
|
+
"CodebaseGraph",
|
|
36
|
+
"CausalCrashCompiler",
|
|
37
|
+
"BlackboxMCPServer"
|
|
38
|
+
]
|
|
39
|
+
|