When you restore a Mac from Internet Recovery, it restores the OS version that came with the Mac when it was shipped. So if your Mac came with Mavericks than it will reinstall Mavericks. From there, you can then install Mojave just above the top of the new Mavericks installation.
It will not install beta OS versions, as it must have an operating system in place with the required macOSPublicBetaAccessUtility installed.
As for the recovery partition's OS version, I'm unsure what happens to it during major macOS upgrades. I would think that would not change as Internet Recovery works even with the recovery partition deleted. Which tells me that Internet recovery (at least for the most part) is built into firmware on the Mac.
Going back a revision or two and then upgrading from there works just fine, it just takes longer. For that reason, I always create a bootable USB installer for the last two versions of macOS and store them in a drawer for eventualities like these. 8 GB flash drives are cheap, and it takes little time to create a bootable macOS installer. Maybe something to consider for the future.