WeKnora/internal/application/service/retriever
ochan.kwon fd3d9f547c feat(search): fan-out KB retrieval across bound vector stores
Multi-KB hybrid search now groups KBs by their bound VectorStore (partition
key (storeID, owner_tenant_id)), retrieves in parallel via errgroup with a
SetLimit(4) cap and a per-group timeout (MULTI_STORE_RETRIEVE_TIMEOUT_SEC,
default 30s), and merges results. When the collected results span more than
one engine type, an EngineAwareNormalizer rescales vector scores to [0, 1];
keyword (BM25) scores pass through to the existing RRF fusion. Single-group
calls take the fast path with zero fan-out overhead, preserving today's
behavior for deployments where every KB has vector_store_id = NULL.

Embedding-model consistency is now enforced explicitly via
ResolveEmbeddingModelKeys. Multi-KB searches across KBs whose resolved
model identities differ return BadRequest instead of silently producing
incomparable scores. Cross-tenant Organization-shared KBs are preserved by
partitioning on KB.TenantID so the factory's ownership lookup runs against
the source tenant. Foreign-tenant KB UUIDs injected via the request body
are rejected via kbShareService.HasTenantKBPermission (Plan 3 of #1303,
3-D capped) before any retrieval; rejected scopes surface as 404 to avoid
leaking foreign KB existence.

Service-layer typed AppErrors (ErrVectorStoreBindingInvalid 2200 /
ErrVectorStoreUnavailable 2201) are mapped from PR2 sentinel hierarchy and
preserved end-to-end: the iterative FAQ path returns them rather than
swallowing, and the HybridSearch handler routes typed AppErrors to the
client unchanged instead of downgrading to 500.

Part of #993 (Phase 2: Per-KB VectorStore Binding).
Phase 2 roadmap item: PR 4 (Multi-store fan-out search).
Depends on #994, #1310, #1372.
2026-05-20 22:25:39 +08:00
..
composite.go feat: 批量更新tag时更新索引字段 2025-12-30 19:44:53 +08:00
factory.go feat(knowledge-base): validate vector store bindings on create, copy, and delete 2026-05-18 15:58:46 +08:00
factory_test.go feat(knowledge-base): validate vector store bindings on create, copy, and delete 2026-05-18 15:58:46 +08:00
keywords_vector_hybrid_indexer.go feat(retriever): exponential backoff + safety truncation for embeddings 2026-05-06 17:17:07 +08:00
normalizer.go feat(search): fan-out KB retrieval across bound vector stores 2026-05-20 22:25:39 +08:00
normalizer_test.go feat(search): fan-out KB retrieval across bound vector stores 2026-05-20 22:25:39 +08:00
ownership.go refactor(retriever): introduce factory for KB-scoped retrieve engine resolution 2026-05-14 15:53:58 +08:00
registry.go refactor(retriever): introduce factory for KB-scoped retrieve engine resolution 2026-05-14 15:53:58 +08:00
registry_test.go feat: add registry dual-map and engine factory for VectorStore 2026-04-17 00:15:37 +08:00