Debug a scenario where a distributed training job is experiencing significant performance degradation.
Implement diagnose_training_degradation(records, threshold) to aggregate timing records, identify ranks whose average step time exceeds the global average by threshold, and classify the dominant bottleneck as compute, communication, or balanced.
Each record is a dictionary with integer step and rank fields plus numeric compute_ms and communication_ms fields. Return a dictionary containing sorted stragglers and the bottleneck classification.
def diagnose_training_degradation(records, threshold):