My tutorial "Build a Secure RAG API" makes three claims a multi-tenant RAG API depends on: filter by tenant and role inside the retrieval query, before the top k are chosen, keeping k results with pgvector's iterative scans; back that filter with row-level security, with an app role that doesn't own the tables and a principal that lasts one transaction; and refuse before calling the model when nothing relevant was found. Its companion code demonstrates each on two tenants with a fake embedder.
This experiment measures them where they matter: one pgvector index shared by 30 synthetic tenants, from one holding a third of the index down to tenants under a quarter of a percent, all writing about the same 32 support topics in their own products and numbers. Real Voyage embeddings, real PostgreSQL 18, the tutorial's schema, roles and policies, on a throwaway database the harness creates and drops.
Three studies: where the filter goes (recall against an exact scan, checked with numpy, for 287 questions); which layer catches which bug (the tutorial's cross-tenant probe under six bugs and three defences); and refusals and citations (100 questions answered by Claude with the tutorial's prompt). The first two need no model. About USD 0.50 in all.
The retrieval and isolation claims all held, more sharply than I expected: filtering inside a plain HNSW query was exactly as bad as post-filtering a top-40, and RLS alone was worse than the explicit filter for the largest tenant. The refusal claim had nothing to test: neither model ever answered an unanswerable question, so the threshold could only turn good answers away.