>> I should have actually asked for examples where time signatures in
>> one staff share the same horizontal space with key signatures in
>> another staff. As it turns out, the problem affects only pieces
>> with two staves per system:
>> https://gitlab.com/lilypond/lilypond/-/merge_requests/3224
>
> Sigh. No, it doesn't. [...]
Sloppy wording on my side, sorry. This remark was not targeting
LilyPond's algorithm but rather how it is done in published music.
>> As soon as there are more staves involved, it's rather clear that
>> time signatures must always come after key signatures so that they
>> can be properly aligned vertically in the score.
>
> Reminds me of the simple rule to figure out where a mathematical
> proof goes wrong. Just look for the first occurence of a phrase
> like "it is rather clear", "obviously" or similar.
The same. Not related to the algorithm but how music typesetters
print scores.
Werner