Solution (source code)

= Solution

Let $S=\sum_s(D_s-\bar D)^2$. Integrating out $M_0$ gives
$$
\boxed{
p(\tau^2\mid D)\propto
(\tau^2)^k(\tau^2+\sigma^2)^{-(N-1)/2}
\exp\left[-\frac{S}{2(\tau^2+\sigma^2)}\right]\mathbf1_{\{\tau^2\geq0\}}}.
$$
Near zero, integrability requires $k>-1$; at infinity it requires
$$
k-\frac{N-1}{2}<-1.
$$
For integer $k$ the posterior is proper exactly when
$$
\boxed{0\leq k<\frac{N-3}{2}}.
$$
The choice $k=0$ is allowed for $N>3$ and yields a proper posterior, but it is an improper flat prior on a scale parameter and is not invariant under reparameterization, so sensitivity to more principled scale priors should be checked.