*Below, I've focused on PA when lots of other theories would do. If replacing PA with a different theory leads to a more answerable question, feel free to do so.*

The *standard system* of a nonstandard model $M$ of PA is the set of sets of natural numbers coded by elements of $M$: $$SS(M)=\{X\subseteq\omega: \exists a\in M\forall x\in\mathbb{N}(x\in X\iff p_x\vert a)\}.$$ *(Here "$p_i$" denotes the $i$th prime.)* An easy overspill argument shows that $SS(M)$ is always a Scott set,$^1$ and Scott proved that every countable Scott set is the standard system of some nonstandard model.$^2$

We can define an analogous notion$^3$ of standard system with $\mathbb{N}$ replaced with more general initial segments: if $M\subsetneq_{end} N$ are models of PA, then we let $SS_M(N)$ be the set of elements of $M$ coded by elements of $N$: $$SS_M(N)=\{X\subseteq M: \exists a\in N\forall x\in M(x\in X\iff p_x\vert a)\}.$$ *(Here "$p_i$" denotes the $i$th prime in the sense of $N$, or equivalently in this case of $M$.)* The same overspill argument shows that the second-order structure $(M, SS_M(N))$ is a model of WKL.

My question is whether the analogue of Scott's theorem holds, at least for countable $M$:

Question.Suppose $M$ is a countable model of PA and $\mathcal{X}$ is a countable family of subsets of $M$ such that $(M, \mathcal{X})\models$ WKL. Is there an $N\supsetneq_{end} M$ such that $SS_M(N)=\mathcal{X}$?

The problem here is that in the usual case, we don't need to worry about $\subseteq$ versus $\subseteq_{end}$, whereas that poses a real problem here.

$^1$A set of sets of natural numbers closed under join and Turing reducibility such that for every infinite binary tree in the set, an infinite path through that tree is also in the set. Equivalently, the second-order part of an $\omega$-model of WKL.

$^2$The generalization of Scott's theorem to *uncountable* Scott sets is wildly open. Knight and Nadel generalized Scott's theorem to Scott systems of cardinality $\aleph_1$, thus solving the problem under the assumption of CH, but their argument breaks down immediately for models of cardinality $\aleph_2$ or greater. Meanwhile, Gitman has recently shown that the question has an affirmative answer for a class of Scott sets characterized in terms of forcing, assuming the set-theoretic hypothesis PFA (which contradicts CH); however, my understanding is that her arguments really only apply to that particular class of Scott sets and that the hypothesis of PFA is currently necessary.

$^3$I've had trouble finding much literature on this, especially compared to the usual notion of a standard system, but Kossak and Schmerl's book does contain some information about them (especially in Chapter $7$).