As Ben notes the right answer is to reparameterize your model.
When you have a holonomic constraint of the form f(x_1, …, x_n) = 0
then you don’t have n degrees of freedom but rather (n - 1). If you
try to sample from the over constrained space, (x_1, …, x_n), directly
then you’ll spend an infinite amount of time trying to perturb your initial
state into one that satisfies the constraint*.
So what you really want to do is find (n - 1) parameters, (y_1, …, y_{n-1}),
and a map g : x -> y, such that g \circ f(y_1, …., y_{n-1}) = 0 exactly.
This is what Bob was recommending when he suggested taking any
y_1, …, y_{n - 1}
and define the map
x_{i} = y_{i}, i < n
x_{n} = - sum_{j = 1}^{n} x_{j}.
By construction you always satisfy the constraint.
The only tricky bit that you’d a have to worry about is that if you want to
assign a prior on x space then you’ll have to keep the Jacobian in mind,
as
p(y) = p(x(y)) | dx / dy |.
* There’s a clever geometric way to handle such constraints, which
is what the Shake and Rattle integrators exploit to simulate non-Hamiltonian
systems, but we don’t do anything like this in Stan at the moment.