  Let $Z=(Z_t)_{t\ge0}$ be a regular diffusion process started at $0$, let
$\ell$ be an independent random variable with a strictly increasing and
continuous distribution function $F$, and let $\tau_{\ell}=\inf\{t\ge0\vert
Z_t=\ell\}$ be the first entry time of $Z$ at the level $\ell$. We show that
the quickest detection problem
\[\inf_{\tau}\bigl[\mathsf{P}(\tau<\tau_{\ell})+c\mathsf{E}(\tau
-\tau_{\ell})^+\bigr]\] is equivalent to the (three-dimensional) optimal
stopping problem \[\sup_{\tau}\mathsf{E}\biggl[R_{\tau}-\int
_0^{\tau}c(R_t)\,dt\biggr],\] where $R=S-I$ is the range process of $X=2F(Z)-1$
(i.e., the difference between the running maximum and the running minimum of
$X$ ) and $c(r)=cr$ with $c>0$. Solving the latter problem we find that the
following stopping time is optimal: \[\tau_*=\inf \bigl\{t\ge0\vert
f_*(I_t,S_t)\le X_t\le g_*(I_t,S_t)\bigr\},\] where the surfaces $f_*$ and
$g_*$ can be characterised as extremal solutions to a couple of first-order
nonlinear PDEs expressed in terms of the infinitesimal characteristics of $X$
and $c$. This is done by extending the arguments associated with the maximality
principle [Ann. Probab. 26 (1998) 1614-1640] to the three-dimensional setting
of the present problem and disclosing the general structure of the solution
that is valid in all particular cases. The key arguments developed in the proof
should be applicable in similar multi-dimensional settings.
