Solution (source code)

= Solution

Let $L_0=100\,\mathrm m$ be the train's <proper length>, $D=90\,\mathrm m$ the tunnel's length in the track <reference frame>, and $v=0.99c$. The <Lorentz factor> is $\gamma=7.0888$. At one track-frame <time>, <length contraction> makes the train
$$
L=\frac{L_0}{\gamma}=14.107\,\mathrm m<D.
$$
\b[Yes, the whole train fits inside at a single track-frame time.] Set $t=0$ when the rear enters the near portal. Until the front reaches the far portal, the rear and front are at $vt$ and $vt+L$, respectively. Complete containment lasts
$$
0\le t\le\frac{D-L}{v},
$$
a track-frame interval of approximately $256\,\mathrm{ns}$, counting boundary contact.

In the train's <reference frame>, its length is $100\,\mathrm m$, while the moving tunnel has simultaneous length $D/\gamma=12.696\,\mathrm m$. \b[No single train-frame time has the whole train between the portals.] The two answers refer to different simultaneity slices.

For an explicit check, denote the rear-entry event by $A$ and the front-exit event by $B$. In track coordinates,
$$
\Delta t=\frac{D-L}{v}>0,\qquad \Delta x=D.
$$
The <Lorentz transformation> gives
$$
\boxed{\Delta t'=\gamma\left(\Delta t-\frac{vD}{c^2}\right)
=\frac{D/\gamma-L_0}{v}<0.}
$$
Thus the front leaves before the rear enters in train coordinates. These spatially separated events have a frame-dependent order, as allowed by <relativity of simultaneity>; neither answer asserts a different local event at a portal. No collision with closed doors has been stipulated.