reembedAll method

Future<void> reembedAll({
  1. void onProgress(
    1. RagReembedProgress progress
    )?,
  2. int batchSize = 32,
})

Resolve an embeddingFingerprintLock by re-embedding every chunk with the currently loaded model.

The flow is resumable: progress is persisted per chunk on the Rust side, so killing the app mid-stream and restarting will let a subsequent reembedAll() pick up where this one left off without re-doing finished chunks. onProgress is invoked once per chunk with the cumulative (done, total) snapshot for the current run.

On success the lock is cleared and the HNSW index is rebuilt with the new embeddings. Throws StateError if no mismatch is active.

Cold-start latency budget for this call is "background, minutes-scale" — host apps SHOULD surface progress UI.

Implementation

Future<void> reembedAll({
  void Function(RagReembedProgress progress)? onProgress,
  int batchSize = 32,
}) async {
  final lock = _fingerprintLock;
  if (lock == null) {
    throw StateError(
      'reembedAll() called but no embedding fingerprint mismatch is active.',
    );
  }
  if (batchSize <= 0) {
    throw ArgumentError.value(batchSize, 'batchSize', 'must be positive');
  }
  return _runOperation(() => _reembedAll(onProgress, batchSize));
}