nextSourceAfter function
The next source to try after failed, or null when the chain is exhausted.
Returns null for a source that is not in the chain at all, so a pipeline
the user picked by hand fails with its own error instead of silently
restarting the platform chain from somewhere in the middle.
Implementation
String? nextSourceAfter(String failed, List<String> candidates) {
final int index = candidates.indexOf(failed);
if (index == -1 || index + 1 >= candidates.length) return null;
return candidates[index + 1];
}