run.veric.dev

Knight Capital — August 1, 2012

Cost: ~$460M pre-tax loss in 45 minutes · Time-to-detect: ~45 min (markets open to manual halt) · Root cause class: T4 (cardinality / control-flow on stale flag)

What happened

Knight Capital, then a major US equity market-maker, lost roughly $460 million in 45 minutes when the market opened on August 1, 2012. The firm nearly went under and was acquired within months. Per the SEC's October 2013 enforcement order, a technician deploying new "Retail Liquidity Program" (RLP) code to Knight's SMARS routing system copied the new code to seven of eight servers. The eighth still ran a decade-old function called "Power Peg" — and the new release reused a configuration flag that the old code interpreted as "fire test orders forever." When the market opened, the eighth server pumped millions of unintended orders into 154 stocks before anyone shut it down.

The pattern

A boolean flag was repurposed by a new version, but at least one running instance still held the old code that read the flag with the old meaning. The same input bytes meant two different things depending on which binary received them. Any system that mutates the semantics of an input field without retiring every reader of the prior semantics has this exposure: schema migrations that change a column's meaning, feature flags reused after a kill, dbt model rewrites that invert a boolean. The runtime invariant — "all live consumers agree on what flag X means" — is provable at deploy time and missing from almost every data deployment pipeline today.

How veric would catch it

veric flags any change that rebinds the meaning of a referenced symbol while a transitive consumer is still configured against the old meaning. In a PR diff against the offending commit, the verifier would have surfaced: "flag power_peg_enabled is referenced by SMARS::route_order (active in current build) AND by deprecated power_peg::dispatch — semantics differ; deploy gate FAIL." This is a T4 control-flow / cardinality check on flag-reachability; the same primitive catches "stale boolean still referenced by dashboard view" in a dbt project.

Try it: open the example below and watch the verdict change as you toggle the offending pattern on and off.

See also

Sources

Replay · structurally similar SQL
trade_window.sql · Knight 2012 patternplaying · line 1/9
1-- Daily trade rollup for the last 7 days, per symbol.
2SELECT
3 symbol,
4 SUM(qty) AS total_qty,
5 COUNT(*) AS n_trades
6FROM trades
7WHERE date BETWEEN d1 AND d1 - INTERVAL '7 days'
8 AND status = 'filled'
9GROUP BY symbol;
abstract values
(waiting for the verifier to bind values…)
Reproduce in playgroundT4 · Cardinality / control-flow in the glossary

Opens the playground pre-loaded with a model that exhibits this pattern. Toggle the offending lines to watch the verdict change.