Other users have posted more intuitive explanations for what the bug is.
Regardless of where any intersections (along a noncritical path) occurs or how they branch into sub-paths, the total distance of any room from the critical path should never exceed 6 tiles – e.g:
But under certain circumstances (which might involve the outer border of the Underspire map) this check simply fails outright, maybe at the latest intersection the distance counter resets to zero or something, but either way THAT is the bug.