[ty] Use diagnostic message as tie breaker when sorting by jelle-openai · Pull Request #25424 · astral-sh/ruff (original) (raw)

Nondeterminism

When ty checks files in parallel, non-panic diagnostics with the same rendered source location, severity, and diagnostic ID can be printed in worker-completion order instead of a canonical order. This manifests as nondeterminism on the homeassistant/core project.

Root Cause

CollectReporter receives checked-file diagnostics as Rayon workers finish, then sorts them with Diagnostic::rendering_sort_key. The existing key compared primary file/range, severity, and diagnostic ID, but not the visible diagnostic message. In core, the two diagnostics had the same primary span and tied on error DiagnosticId::InvalidArgumentType, so the sort key considered visibly different diagnostics equal and Rust's stable sort preserved the race-dependent arrival order.

Fix

Use the concise rendered message as the final tie-breaker.