Thinking about this more, the issue with simultaneous transposition and key changes is worse than I realized, since it's pretty common to write something like:
global = {
s1
\key e \major
s1
}
music = {
g'1
\transposition a
g'1
}
\new Staff \with {
\autoTranspose
} <<
\global \music
>>
The output is incorrect (but differently wrong) regardless of whether you write << \global \music >> or << \music \global >>.
This is partially a bug in the original snippet, not just my version with inserted key signatures. Solving it would seem to require the ability to "listen ahead" or "listen behind" to all the events happening at the same moment. Is that even possible?