Double jeopardy only applies to not guilty verdicts, not mistrials.
I thought the judge could find that jeopardy had attached, and declare that a defendant could not be retried.
Basically, the judge applies his own judgement to the case. If he thinks the prosecution has not proven the case to his satisfaction, he can bar them from taking another bite at the apple.
You can indict a ham sandwich, but you can’t prosecute a ham sandwich indefinitely.