secureKeyDiagnosticLine function
Collapses a diagnostic to one log-safe line: trim → collapse internal whitespace → keep the LAST 200 chars (failures announce themselves in the tail). The ONE canonical collapse (gh-1059 review): both the preload error paths and the platform runner's captured stderr go through it, so boot diagnostics and helper diagnostics can never drift apart (a diverged cap would truncate the two surfaces differently).
Implementation
String secureKeyDiagnosticLine(String text) {
final flat = text.trim().replaceAll(RegExp(r'\s+'), ' ');
return flat.length > 200 ? flat.substring(flat.length - 200) : flat;
}