Thanks, that actually helps a bit, and I've tried a few different ways to replicate to try to get the same effect you're describing. Someone else found a very similar issue:
https://mods.factorio.com/mod/WhistleStopFactories/discussion/5d3c0be511e5ec000d2ecfcf
But I can't replicate it. My code looks like it should do what I want it to do and when I try it, it works for me. If you don't mind disabling achievements, you should be able to restore all recipes with the following command:
/c game.player.force.reset_technology_effects()
Which will disable achievements.
Other than that I've re-read my code a few more times and tried a few different ways to replicate, and can't get the same thing so I don't know how to fix it. It isn't just you that is having this problem, so it absolutely appears to be a bug in my code, but I'm not sure I'll be able to solve it until I'm able to replicate it.
Thanks for the report, sorry I couldn't be more help.