Analysis & Notebooks Guide¶
Purpose: Interactive experiment analysis with Jupyter notebooks. Commands:
crucible notebook| Module:crucible.analysis
1. Quick Start¶
# Install dependencies
pip install "crucible[jupyter]"
# or: uv sync --extra jupyter
# Launch Jupyter with the notebooks/ directory
crucible notebook
# Or with custom options
crucible notebook --port 9999 --no-browser
Jupyter opens at http://localhost:8888/tree with the notebooks/ directory as the root.
2. The crucible.analysis Module¶
The analysis module provides pandas-based helpers for loading experiment run data:
from crucible.analysis import (
load_run, # Load run manifest as dict
load_events, # Load events as DataFrame
load_gas, # Load gas profile as DataFrame
load_storage_diffs,# Load storage changes as DataFrame
load_cross_chain, # Load cross-chain messages as DataFrame
load_balance_diffs,# Load balance changes as DataFrame
load_agent_reasoning, # Load LLM agent reasoning traces as DataFrame
find_run, # Find run directory by ID
list_runs, # List all available runs
)
# Load run data
manifest = load_run("DS-2026-00001")
events = load_events("DS-2026-00001")
gas = load_gas("DS-2026-00001")
diffs = load_storage_diffs("DS-2026-00001")
agent_traces = load_agent_reasoning("DS-2026-00001")
# Explore
print(f"Outcome: {manifest['outcome']}")
print(f"Gas by phase: {gas.groupby('phase')['gas_used'].sum()}")
# Compare two runs
from crucible.diff import compare_runs
result = compare_runs(find_run("DS-2026-00001"), find_run("DS-2026-00002"))
print(f"Deterministic: {result['storage_equal'] and result['events_equal']}")
3. Included Notebooks¶
notebooks/experiment_analysis.ipynb provides 6 ready-to-run cells:
- Load experiment data — imports and loads a run by ID
- Gas analysis — bar chart, pie chart, publication-ready gas tables
- Event timeline — scatter plot of decoded contract events
- Storage diff analysis — top modified contracts and slot counts
- Run comparison — determinism check between two runs
- LaTeX export — publication-ready gas profile tables
4. Discovering Run IDs¶
from crucible.analysis import list_runs
for r in list_runs():
print(f"{r['run_id']} — {r['scenario']} ({r['outcome']})")
5. Operational Guidelines¶
- Targeting Runs: Set
RUN_IDat the top of the notebook to your target experiment ID. - Output Routing: The
figures/directory is created automatically for exported charts. - Rendering: Use
%matplotlib inlinefor inline rendering (already the default in Jupyter).