An extremely rare bug
From what it looks like:
When stem bit 1 is mapped to something, but then insert a stem block before it and map new stem bit 3 to a leaf, the algorithm thinks that the new 3 is after the old 1 when it isn't anymore, so doesn't update it.
<<When inserting a new stem into the final layer, update stem_to_leafs to match it>>
Explore further