stop method
Stops the scheduler and cancels all running workers/timers.
Idempotent: calling stop() repeatedly (or after a scheduler that was
driven via direct tick() invocations without start()) still releases
in-memory bookkeeping so callers can rely on it for cleanup.
Implementation
Future<void> stop() async {
final wasRunning = _running_;
_shuttingDown = true;
_running_ = false;
_pollTimer?.cancel();
_pollTimer = null;
for (final entry in _retryAttempts.values) {
entry.timer?.cancel();
}
_retryAttempts.clear();
final cancellations = <Future<void>>[];
for (final entry in _running.values.toList()) {
cancellations.add(entry.subscription.cancel());
}
await Future.wait(cancellations);
_running.clear();
_claimed.clear();
_changedFilesByRun.clear();
_retryHistoryByIssue.clear();
_proofPathsByIssue.clear();
_turnsByIssue.clear();
if (wasRunning) {
_record('scheduler_stopped', 'Scheduler stopped.');
}
}