wtf( )unctionsystem design, drawn
← all problemsAI EngineeringHard

One tenant's documents crowding out another's

Every customer's chunks live in one collection, and results are filtered by tenant in application code after the search returns. One large customer dominates the neighbourhood, so small tenants get two results instead of ten — and a bug in that filter once let another company's contract text into an answer.

The filter is in the wrong place. Search reads across every tenant and you discard the rest afterwards.

Move the tenant boundary into the search itself.
Components — tap one, then tap a slot on the diagram
!A small tenant got two results instead of ten. Once, someone got another company's contract.

Boundaries, outermost first: Vector store: Tenant A vectors, Tenant B vectors Outside every boundary: Tenant A, Tenant B, Retrieval API (FAILED: leaked), an empty slot for the scope the search Connections: Tenant A calls Retrieval API (step 1) Tenant B calls Retrieval API Retrieval API calls scope the search — tenant id (step 2) scope the search calls Tenant A vectors (step 3) scope the search calls Tenant B vectors

Tenant A
Tenant B
Tenant A vectors
Tenant B vectors
Retrieval APIleaked