ADR-017: Embedding as Plugin-Provided Service

Status

Accepted

Context

QNTX's embedding engine (ONNX inference + HDBSCAN clustering) was compiled into the main binary via CGO/Rust FFI, gated behind cgo && rustembeddings build tags. This created build complexity, prevented hot-reload, and locked to a single hardcoded model (384-dim).

The existing provider pattern (ADR-014 for LLM, ADR-015 for search) provides the model: a plugin declares embedding_provider = true during Initialize, QNTX routes embedding calls to it via gRPC.

Decision

Add embedding_provider to the plugin provider pattern. Any plugin implementing EmbeddingService gRPC (Embed, BatchEmbed, Cluster, ModelInfo) alongside DomainPluginService can serve as the embedding backend. QNTX creates a PluginEmbeddingService that satisfies the existing Service interface by making gRPC calls to the plugin instead of CGO/FFI calls.

Protocol changes

Plugin side

Core side (QNTX)

Pure Go operations (no RPC needed)

SerializeEmbedding, DeserializeEmbedding, ComputeSimilarity are pure math — implemented directly in Go on PluginEmbeddingService, not routed through gRPC.

Consequences