Storage class handles all database operations with thread-safety for parallel batch runs.
Database Location
Default:~/.ai-blackteam/results.db
Override via config:
:memory: for in-memory testing:
Connection Setup
check_same_thread=False- Allows the connection to be used from multiple threads (protected by the lock)PRAGMA journal_mode=WAL- Write-Ahead Logging allows concurrent reads during writesPRAGMA busy_timeout=5000- Waits up to 5 seconds for a lock instead of failing immediately
Schema
Three tables:runs
Every attack execution creates one row.turns
Every message in a conversation gets a row. Single-turn attacks have 2 turns (user + assistant). Multi-turn attacks have 2 per round.tool_calls
Every tool call from a tool-use attack gets a row.Thread Safety
All write operations are wrapped in a threading lock:run_batch_parallel creates multiple Engine instances (one per thread), all writing to the same database file. WAL mode handles concurrent reads, and the lock serializes writes.
Query Methods
sqlite3.Row factory).
Querying Directly
You can query the database directly with any SQLite tool:Source
src/ai-blackteam/storage/sqlite.py