Sometimes the space is not valid when the windowVisible event callback is called, immediately after a new window is created. PaperWM:addWindow() will bail, but PaperWM:tileSpace() will try to tile this window when the windowFocused event callback happens, shortly afterwards. Since it appears that the window's space is valid once we get to this second callback, try to add the window during PaperWM:tileSpace() and see if the spaces match.
Sometimes the space is not valid when the windowVisible event callback is called, immediately after a new window is created. PaperWM:addWindow() will bail, but PaperWM:tileSpace() will try to tile this window when the windowFocused event callback happens, shortly afterwards. Since it appears that the window's space is valid once we get to this second callback, try to add the window during PaperWM:tileSpace() and see if the spaces match.