I'm going to rephrase this as 'even when a project has an external bug tracker, bug references are always linkified within LP.' This suggests a reasonable first approximation: use the tracker that most of the contexts use when linkifying bug text. For code there will always be one context, for bug comments there may be many (and we don't [currently] record the originating context, so we would inherit the bug context).
I'm going to rephrase this as 'even when a project has an external bug tracker, bug references are always linkified within LP.' This suggests a reasonable first approximation: use the tracker that most of the contexts use when linkifying bug text. For code there will always be one context, for bug comments there may be many (and we don't [currently] record the originating context, so we would inherit the bug context).