resolveFor method

The tokenizer factory an embedding backend's describe() puts in its pass config — what a TokenEmbeddingPass builds its tokenizer with.

Throws rather than returning null, and names the fix: a backend that silently fell back to one tokenizer family would not fail — it would return vectors that are quietly the wrong point in the embedding space, which no test downstream can distinguish from a working model.

Implementation

EmbeddingTokenizerFactory resolveFor(EmbeddingModelSpec spec) {
  final provider = findFor(spec);
  if (provider == null) {
    throw StateError(
      'No embedding tokenizer is configured. flutter_edge_ai core ships the '
      'tokenizer CONTRACT but no implementation — they are opt-in, like RAG '
      'stores. Add flutter_edge_ai_embeddings to pubspec.yaml and pass its '
      'provider to FlutterEdgeAi.initialize(embeddingTokenizers: ...):\n'
      '  • flutter_edge_ai_embeddings → GemmaEmbeddingTokenizers()\n'
      'Spec: ${spec.name}',
    );
  }
  return provider.factory;
}