Skip to main content

Module embedder

Module embedder 

Source
Expand description

Component embedder — computes and stores semantic-search embeddings for the A2UI design-system component catalog.

Ported in spirit (not verbatim) from flint-forge/crates/fdb-gateway/src/a2ui_embedder.rs. The flint-forge source is a long-running Postgres LISTEN/NOTIFY background task that calls an in-database llm.embed() function. UAR has no equivalent in-database embedding function and its default/server-full persistence backend is SurrealDB, not Postgres — so this port:

  • Uses UAR’s existing EmbeddingBackend trait (src/uar/rag/embeddings/mod.rs) to generate embeddings, instead of a bespoke in-database function call.
  • Operates over the backend-agnostic DesignSystemStore trait instead of a raw sqlx::PgPool + Postgres channel listener, so it works with the in-memory, SurrealDB, and Postgres store implementations alike.
  • Exposes embed_component (embed one component on demand — the equivalent of flint-forge’s per-notification handler) and backfill_missing (embed every component that doesn’t have one yet — the equivalent of flint-forge’s startup backfill). Live-notification fan-out (the a2ui_embed channel) is deferred to Change 20 (a2ui-realtime-backbone-from-flint-realtime-fabric), which wires the flint-realtime-fabric SSE/fan-out backbone UAR will use for all A2UI live updates — building a second, one-off notification mechanism here would be redundant with that change’s scope.

The fallback-on-unavailable-model behavior (try a primary model, then a secondary) from flint-forge’s text-embedding-3-large → text-embedding-3-small fallback is preserved as an optional secondary backend parameter.

Enums§

EmbedError
Errors that can occur while embedding a component.

Functions§

backfill_missing
Embed every component that does not yet have an embedding. Errors on individual components are logged and do not abort the backfill (matches flint-forge’s backfill_missing best-effort behavior). Returns the count of components successfully embedded.
build_embedding_text
Build the embedding input string from component metadata. Mirrors flint-forge’s build_embedding_text.
embed_component
Embed a single component and persist the result via the store’s set_component_embedding. If fallback is provided and the primary backend fails with BackendUnavailable, retries with fallback.