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
EmbeddingBackendtrait (src/uar/rag/embeddings/mod.rs) to generate embeddings, instead of a bespoke in-database function call. - Operates over the backend-agnostic
DesignSystemStoretrait instead of a rawsqlx::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) andbackfill_missing(embed every component that doesn’t have one yet — the equivalent of flint-forge’s startup backfill). Live-notification fan-out (thea2ui_embedchannel) is deferred to Change 20 (a2ui-realtime-backbone-from-flint-realtime-fabric), which wires theflint-realtime-fabricSSE/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§
- Embed
Error - 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_missingbest-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. Iffallbackis provided and the primarybackendfails withBackendUnavailable, retries withfallback.