[step:Build geodesic segments from iterated midpoints]
Fix $x_0,x_1 \in X$ and write $L := d(x_0,x_1)$. If $L = 0$, the constant map
\begin{align*}
\gamma: [0,L] &\to X \\
t &\mapsto x_0
\end{align*}
is a geodesic segment.
Assume $L > 0$. By the midpoint construction, we inductively choose points $x_q \in X$ for every dyadic rational $q \in [0,1]$, meaning every number of the form $q = a2^{-r}$ with $a,r \in \mathbb{N} \cup \{0\}$ and $0 \leq a \leq 2^r$. Start with the prescribed endpoints $x_0$ and $x_1$. Suppose the points at level $r$ have been chosen so that
\begin{align*}
d(x_{a2^{-r}},x_{b2^{-r}}) = (b-a)2^{-r}L
\end{align*}
for all integers $a,b$ with $0 \leq a \leq b \leq 2^r$. For each $a \in \{0,\dots,2^r-1\}$, insert a midpoint $x_{(2a+1)2^{-(r+1)}}$ between $x_{a2^{-r}}$ and $x_{(a+1)2^{-r}}$. Adjacent level-$(r+1)$ distances are then all equal to $2^{-(r+1)}L$.
For non-adjacent level-$(r+1)$ points, the triangle inequality gives the upper bound by summing adjacent distances along the dyadic chain. The lower bound follows from the triangle inequality applied to the complementary pieces of the same chain: if $0 \leq a \leq b \leq 2^{r+1}$, then
\begin{align*}
L
=
d(x_0,x_1)
\leq
d(x_0,x_{a2^{-(r+1)}})
+
d(x_{a2^{-(r+1)}},x_{b2^{-(r+1)}})
+
d(x_{b2^{-(r+1)}},x_1).
\end{align*}
The two outer terms are already equal to $a2^{-(r+1)}L$ and $(2^{r+1}-b)2^{-(r+1)}L$ by the adjacent-chain upper bound. Rearranging gives
\begin{align*}
d(x_{a2^{-(r+1)}},x_{b2^{-(r+1)}}) \geq (b-a)2^{-(r+1)}L.
\end{align*}
Together with the upper bound, this proves
\begin{align*}
d(x_q,x_{q'})
=
|q-q'|L
\end{align*}
for all dyadic rationals $q,q' \in [0,1]$.
Define
\begin{align*}
\gamma_0: [0,1] \cap \mathbb{Q}_{\mathrm{dyad}} &\to X \\
q &\mapsto x_q,
\end{align*}
where $\mathbb{Q}_{\mathrm{dyad}} := \{a2^{-r} : a,r \in \mathbb{N} \cup \{0\}\}$. The distance identity shows that $\gamma_0$ is $L$-Lipschitz on the dyadic rationals. Since $X$ is compact, hence complete, and the dyadic rationals are dense in $[0,1]$, $\gamma_0$ extends uniquely to a continuous map
\begin{align*}
\gamma: [0,1] &\to X.
\end{align*}
For arbitrary $s,t \in [0,1]$, choose dyadic sequences $(s_n)_{n \in \mathbb{N}}$ and $(t_n)_{n \in \mathbb{N}}$ with $s_n \to s$ and $t_n \to t$. Continuity of $\gamma$ and of $d$ gives
\begin{align*}
d(\gamma(s),\gamma(t))
=
\lim_{n \to \infty} d(\gamma_0(s_n),\gamma_0(t_n))
=
\lim_{n \to \infty} |s_n-t_n|L
=
|s-t|L.
\end{align*}
Therefore the map
\begin{align*}
\tilde{\gamma}: [0,L] &\to X \\
t &\mapsto \gamma(t/L)
\end{align*}
satisfies
\begin{align*}
d(\tilde{\gamma}(s),\tilde{\gamma}(t)) = |s-t|
\end{align*}
for all $s,t \in [0,L]$. Hence $\tilde{\gamma}$ is a geodesic from $x_0$ to $x_1$.
[/step]