Consider the following stochastic differential equation:
$$dY_t = Z_t dW_t$$ and terminal condition $Y_T = b,$ for which holds: $E[|b|^2] < \infty$ Furthermore b is adapted to the filtration generated by the Browian motion only at terminal time $T$.
$Z_t$ is a predictable square integrable process. So the right hand side $Z_t dW_t$ is martingale.
Why is the solution $Y_t$ adapted to the underlying filtration If I rewrite the equation, I get: $$Y_t = Y_T - \int_t^T Z_s dW_s = b - \int_t^T Z_s dW_s $$.
Since $b$ is only mb w.r.t to terminal time $T$, $Y_t$ cannot be adapted.
Where did I do a mistake?
While it's true that $b$ and $\int_t^T Z_s dW_s$ are not $\mathcal F_t$ measurable, $b - \int_t^T Z_s dW_s$ is $\mathcal F_t$ measurable. That's because $$b - \int_t^T Z_s dW_s = Y_T - \int_t^T Z_s dW_s = \int_0^TZ_s dW_s - \int_t^T Z_s dW_s = \int_0^t Z_s dW_s.$$
If you're confused about why there is a solution to this backwards stochastic differential equation, note that $Y_t := \mathbb{E}[b|\mathcal F_t]$ is a martingale satisfying $Y_T = b$, so by the martingale representation theorem there exists an adapted process $Z$ such that $dY_t = Z_t dW_t$.