This long proposal, most of which I wrote, does not currently fully and precisely address a rather important issue: What does the mechanism that delivers the template from the repository to the local wiki actually deliver—the template's code or its output? The same question also applies to modules: should the Lua code of a global module run on the repo or on the local wiki?
I don't know nearly enough about the intricacies of template parsing and context and about Lua evaluation. But it will be necessary to decide about these things sooner or later, so I need professional help :)
What makes sense to me is that the code should be delivered and parsed on the local wiki, although I might be missing something. This way it will probably be easier to parse it on the local wiki and check whether local version of templates transcluded within this template need to be loaded, and to parse magic words in local context.
Since I am really not an expert on how this works, it's quite possible that I'm totally wrong about this, and that maybe they should be at least partly parsed on the repo.
Tagging some people who may have an idea; feel free to ignore if you're busy with something else :)
(Originally, this post was much longer and detailed my naïve thinking process, but then I decided to just write that process' result. If anyone is interested for some reason, I can post the rest, but it's not really exciting.)