  We prove a conjecture of Schmid and the second named author that the
unitarity of a representation of a real reductive Lie group with real
infinitesimal character can be read off from a canonical filtration, the Hodge
filtration. Our proof rests on three main ingredients. The first is a wall
crossing theory for mixed Hodge modules: the key result is that, in certain
natural families, the Hodge filtration varies semi-continuously with jumps
controlled by extension functors. The second ingredient is a Hodge-theoretic
refinement of Beilinson-Bernstein localization: we show that the Hodge
filtration of a mixed Hodge module on the flag variety satisfies the usual
cohomology vanishing and global generation properties enjoyed by the underlying
$\mathcal{D}$-module. The third ingredient is an explicit calculation of the
Hodge filtration on a tempered Hodge module. As byproducts of our work, we
obtain a version of Saito's Kodaira vanishing for twisted mixed Hodge modules,
a calculation of the Hodge filtration on a certain object in category
$\mathcal{O}$, and a host of new vanishing results for coherent sheaves on flag
varieties.
