But how can it be a mechanical rewrite if the tool used isn't deterministic?

It converges to "almost deterministic" on highly predictable outputs (i.e. code) with the right sampling params (say, you only sample the most probable token without randomness/high temperature) and with self-correction loops