The above position is legal. But add ANY type of piece on g8 and the position becomes illegal. Why?
The white king has to go to h8 and the black king to f7 to let the white rook go to c7. When the white king has moved back to f7, g8 will be vacant and it will be Black's move, but no remaining black piece can ever move to g8. A black piece that tempos while a white knight moves to g8 can't be captured and will still be on the board.
You haven’t mentioned about what happens if a white piece is added to g8. Then the last move must be the uncapture of a black unit on g8 (to give black a last move), but a black unit on g8 is illegal as you have stated. But again, well done!
Here's another way I just thought of to get to the legal position.