Mathematical Fragility Debugger

Your risk model
passes every test.

Then it blows up in prod.

BlackSwan runs 5,000 Monte Carlo simulations under realistic market stress scenarios and pinpoints the exact source line where your math breaks — how often, under what conditions, and which input caused it.

VS Code Extension
Python 3.11+
NumPy / Pandas
MIT License
100% Deterministic
8
Failure detector types
5,000
Iterations per run
100%
Deterministic with seed
<5s
Time to first finding
581
Tests passing

See it find the break

One command. Five thousand simulations. One exact line — with causal chain, frequency, and a ready-to-apply fix.


What no linter can do

Standard linters catch syntax errors. BlackSwan catches the math that looks correct until a 3-sigma event hits it — and tells you exactly where, why, and how to fix it.

01

Finds the exact line

Not "your matrix might be unstable." The exact line. The exact condition. How many times out of 5,000 it broke under that market scenario. 8 detector types run automatically — no configuration.

line 82 · 16.9% failure rate
02

Traces the full causal chain

Every failure includes a dependency walk: which root input caused which intermediate variable to drift, finally breaking the math at which line. Two-Path attribution with Slow-Path replay for verified, high-confidence results.

corr_shift → adj_matrix → cov_matrix
03

Auto-fixes with a deterministic guard

For each shatter point, BlackSwan generates a mathematically sound fix — a nearest-PSD correction, an epsilon clamp, a denominator guard — and applies it in one command.

Higham 2002 nearest-PSD applied
04

CI and Claude integration

Emit SARIF 2.1.0 for GitHub Code Scanning with one flag. Or run stress tests directly from a Claude conversation via the MCP server — findings, causal chains, and fix hints without leaving your IDE.

--output sarif  ·  blackswan-mcp
05

Fully reproducible results

Every run emits a ReproducibilityCard: exact BlackSwan version, NumPy version, scenario hash, seed, and a ready-to-paste replay command. Same seed, same scenario, same results — always.

seed 42 · scenario_hash a3f9c2
06

Adversarial stress mode

Beyond random Monte Carlo: a genetic algorithm evolves perturbation sets toward worst-case inputs. A HardnessAdaptor ramps intensity when no failures are found, so robust code is actually tested hard.

--adversarial --population 200

Five stress regimes, built-in

Each scenario is a reproducible YAML spec. Same seed, same parameters, same results — always.

01

Liquidity Crash

Spread widening, volatility expansion, correlation contagion, and turnover collapse simultaneously.

spread: 1.5×–3.5×
vol: lognormal μ=1.8
corr: +0.10 to +0.35
02

Vol Spike

Sudden volatility regime shift. Tests whether your model survives realized vol 2×–4× above historical.

vol mult: 2×–4×
corr: +0.05 to +0.15
spread: unchanged
03

Correlation Breakdown

Pairwise correlations surge. The classic covariance matrix PSD failure scenario.

corr: +0.20 to +0.50
vol: 1.2×–1.5×
diversification: gone
04

Rate Shock

Parallel rate shift with credit spread widening. Stress tests duration and convexity assumptions.

rates: +100 to +300 bps
spread: +50 to +150 bps
curve: parallel
05

Missing Data

Random NaN injection and partial time series truncation. Finds silent failures from bad data handling.

NaN inject: 5–20%
series: partial truncation
silent: by design

One install. Every interface.

CLI, Python API, VS Code extension, GitHub Actions, and Claude MCP — the engine is the same in all of them.

pip — base package
$ pip install blackswan
CLI — stress test a file
$ python -m blackswan test risk_model.py --scenario liquidity_crash
VS Code extension — install from VSIX
$ code --install-extension blackswan.vsix
SARIF — GitHub Code Scanning
$ python -m blackswan test risk_model.py --scenario liquidity_crash --output sarif --output-path results.sarif
Claude MCP — run from any conversation
$ pip install blackswan[mcp] && blackswan-mcp

Requires Python 3.11+ · NumPy · PyYAML · Full documentation on GitHub