Let $S^\omega$ denote either $\omega^\omega$ or $2^\omega$.
Let's call a function $f: S^\omega \rightarrow$ {0,1} 'nice' if there exists a function $g_f: S^{\lt \omega} \rightarrow 2$ such that for every $x \in S^\omega$: $\lim_{k \rightarrow \infty} g_f( (x_0,...,x_k) ) = f(x)$.
(One could think of this as a calculation of $f(x)$ that 'changes its mind' at most finitely often.)
(Note that this does not imply that $f$ is continuous. Rather, the nice functions correspond to $\Delta_2^0$ sets.)
If $\alpha$ is an ordinal, we call $f$ '$\alpha$-nice' if there exists a function $h_f: S^{\lt \omega} \rightarrow \alpha \times\lbrace 0,1\rbrace$ such that, using the notation $(\alpha(k), n(k)) = h_f( (x_0,..., x_k) )$, we have:
$\lim_{k \rightarrow \infty} n(k) = f(x)$ for all $x \in S^\omega$
$\alpha(k+1) \leq \alpha(k)$ for all $k \in \omega$
whenever $n(k+1) \neq n(k)$, we have $\alpha(k+1) \lt \alpha(k)$
We'll say that $f$ 'has rank' $\alpha$ if $\alpha$ is the minimal ordinal such that $f$ is $\alpha$-nice (if there exists any such $\alpha$).
Questions:
Is every nice function an $\alpha$-nice function for some $\alpha$?
Assuming ZFC but not CH, what is the maximum (or l.u.b.) rank that a nice function can have?