Characterization of martingale diffusions ending in $\{-1,1\}$ Let $\mathcal M$ be the collection of martingle diffusions starting at zero and ending in $\{-1,1\}$. Equivalently, $X\in \mathcal M$ iff there exists a measurable function $a$ s.t. it holds almost surely
$$X_t=\int_0^t a(s,X_s)dW_s ~\in~ [-1,1],~ \forall t\ge 0 \quad\mbox{and} \quad X_{\infty}:=\lim_{t\to\infty}X_t\in \{-1,1\}.$$
What is the condition on $a$ so that the above properties of $X$ can be satisfied? My guess is
$$a(t,x)=(1-|x|)^{p}k(t,x) \quad \mbox{or}\quad a(t,x)={\bf 1}_{\{|x|<1\}}k(t,x)$$
for some $p>0$ and suitable function $k$. The simplest example is given as $a(t,x)={\bf 1}_{\{|x|<1\}}$ by Mateusz Kwaśnicki (Martingale representation of a stopped Brownian motion)
Any answer, comments and references are highly appreciated.
PS : For the time-homogeneous case, i.e. $a(t,x)\equiv a(x)$, Mateusz provides a sufficient and necessary condition on $a$ to ensure the properties of $X$. I still look for the condition for general $a$.
 A: This is an extended comment on the time-homogeneous case, when the coefficient $a(t, x)$ does not depend on $t$, so that it can be written as $a(x)$.
Suppose that $a(\pm 1) = 0$ and that $1/(a(x))^2$ is locally integrable over $(-1, 1)$. We claim that in this case the desired process $X_t$ exists.

Define the speed measure $m$ by
$$ m(x) = \int \frac{1}{(a(x))^2} \, dx . $$
Then there is a (unique) Feller diffusion $X_t$ on $(-1, 1)$ with speed measure $m$ and scale function $s(x) = x$, and this diffusion is a weak solution of the SDE
$$ dX_t = a(X_t) dB_t \qquad \text{for $t$ less than the hitting time of } \{-1, 1\}; $$
for further information and references, see, for example, DOI:10.1007/978-94-009-3859-5_35. (In this book chapter the author seems to assume that $a$ is locally bounded and bounded away from zero, but I believe the result is quite general. Time permitting, I can look up a better reference.)
This diffusion either hits $\{-1, 1\}$ in finite time $\tau$, in which case we extend it past $\tau$ so that $X_t = X_{\tau-}$ for $t \geqslant \tau$, or it stays in $(-1, 1)$ forever, approaching either $1$ or $-1$ as $t \to \infty$. Due to our assumption $a(\pm 1) = 0$, the above extension satisfies the SDE
$$ dX_t = a(X_t) dB_t \qquad \text{for all } t > 0 . $$
Finally, we have already seen that $X_\infty \in \{-1, 1\}$, as desired.

Edit: I believe that the above reference does not really cover the case of general $a(x)$ and processes in an interval. It was meant to give an entry point to the abundant literature on the subject.
However, the construction of $X_t$ is in fact fairly simple. We start with a standard Brownian motion $W_s$ and its local time $L_s^x$ (not really needed here), we denote by $\sigma$ the hitting time of $\{-1, 1\}$ for $W_s$, and we let
$$ T_s = \int_0^{s \wedge \sigma} \frac{1}{(a(W_r))^2} dr = \int_{-1}^1 \frac{L_{s \wedge \sigma}^x}{(a(x))^2} dx . $$
Then $T_s$ is strictly increasing on $[0, \sigma)$ and so it has a continuous inverse function $T_t^{-1}$, defined on $[0, T_\sigma)$ (with $T_\sigma$ possibly infinite). Then we define
$$ X_t = W_{T_t^{-1}} \qquad \text{for } t \in [0, T_\sigma) $$
and $X_t = W_\sigma$ for $t \geqslant T_\sigma$.
Then clearly $X_t$ is a continuous diffusion in $(-1, 1)$ — a time-changed Brownian motion — which either reaches $W_\sigma \in \{-1, 1\}$ in finite time $T_\sigma$ and stays there forever, or it converges to $W_\sigma \in \{-1, 1\}$ as $t \to T_\sigma = \infty$, depending on whether $T_\sigma$ is finite or not.
It remains to see that $X_t$ is a weak solution of $dX_t = a(X_t) dB_t$. To this end, oberve that for $t < T_\sigma$, the quadratic variation of $X_t$ satisfies
$$ d\langle X \rangle_t = d\langle W \rangle_{T_t^{-1}} = dT_t^{-1} = (a(W_{T_t^{-1}}))^2 dt = (a(X_t))^2 dt , $$
and so
$$ dB_t = (a(X_t))^{-1} dX_t $$
defines a continuous martingale $B_t$ with quadratic variation $d\langle B\rangle_t = dt$, hence a Brownian motion, for $t \in [0, T_\sigma)$. Thus $X_t$ indeed solves
$$ dX_t = a(X_t) dB_t $$
for $t \in [0, T_\sigma)$, and extension to $t \geqslant T_\sigma$ is now immediate (expand the probability space to accommodate another Brownian motion $\tilde B_t$, and let $dB_t = d\tilde B_t$ for $t \geqslant T_\sigma$).

In fact, this should be essentially an "if and only if" condition, but due to time limitations I did not try to check this.
