In fiction, especially sf/f Lore is called Worldbuilding and all things flow from it, seminars are given about it, books (by masters) are written about it, and, as a writer, you'd better damn well have your own bible, 90% of which is in your head and not seen. I had one series where I never revealed THE RULES of why a certain thing happened at a certain time (and surprised my characters), but I knew, and I knew I would have to set up certain conditions to trigger those rules, and that when those rules were met the event would be triggered -- so I kept an eye on those bits all the time...
Worldbuilding, Lore, is key.