세 패턴, 세 risk profile
1. Collection-per-tenant
각 tenant 가 자기 Chroma collection 또는 pgvector 테이블. 가장 강한 isolation; 수천 tenant 면 운영 무거워질 수 있음.
2. Shared collection + tenant_id 메타데이터
한 큰 collection, 모든 청크에 metadata.tenant_id, 모든 query 에 where={tenant_id}. 싸고 수백만 tenant 까지 스케일, 근데 누락된 필터가 tenant 가로질러 leak. 엄격히 테스트.
3. Schema-per-tenant (pgvector)
Postgres schema 로 tenant namespace. Single connection pool, 메타데이터 패턴보다 더 깔끔한 isolation. search_path 로 query 자동 scope.
leak 막는 contract
retrieval 을 tenant_id 파라미터를 요구하는 함수로 감싸. 어떤 코드 path 도 tenant_id 없이 retriever 호출 못 하게. 코드 리뷰가 결국 놓치는 걸 컴파일러가 enforce.