stopSync method

  1. @override
Future<void> stopSync()
override

Stop the background sync loop. Idempotent; durable progress is kept (the chain is the source of truth). Pauses sync WITHOUT closing.

Implementation

@override
Future<void> stopSync() async {
  stopCount++;
  final gate = stopSyncGate;
  if (gate != null) await gate.future;
  if (failStop) throw StateError('fake stop failure');
  // FAITHFUL TO THE CORE (#409 R1). `SyncController::stop()` ends by
  // publishing `SyncStatus::Idle` (`sync_controller.rs:328`, pinned by the
  // core's own tests), so every successful stop MOVES THE OBSERVED STATUS.
  // This fake counted the call and pushed nothing, and that omission is not a
  // harmless simplification: it is why the shipped #407 R3 escalation pin
  // passed against a predicate that resets on any non-`Stalled` value. A kick
  // is a stop+start, so in production the kick's own teardown fed `Idle` back
  // into the reset listener and cancelled the very cooldown it had just set —
  // a condition no test could reach while this method stayed silent.
  //
  // Deliberately AFTER the `failStop` throw: the core cannot publish `Idle`
  // for a stop that did not complete.
  push(const SyncStatus.idle());
}