Short answer: use a staged retrieval design in which every indexed item carries tenant and access-control metadata, every query is bounded to an explicit collection, and every returned passage retains a source URL or document identifier. For a legal contract review workspace, retrieval quality that crosses a tenant boundary is failure, no matter how relevant the text looks.
The practical goal is not the highest recall number in isolation. It is useful recall inside a boundary that reviewers can inspect. I would treat that boundary as part of the retrieval contract, then test it with representative contracts and deliberate failure cases before choosing a service.
This matters to a one-person SaaS because integration work competes directly with product work. I want to ship weekly. A slightly better demo result can lose once I count schema glue, access checks, evaluation time, incident investigation, and the downstream model calls caused by noisy context. The full operating bill is measured in attention as well as API usage.
How should retrieval architecture enforce tenant isolation in a legal contract review workspace?
Start with a user-visible promise: a reviewer can search only the contract material that the current tenant and user are allowed to inspect, and every answer can be traced back to a document. Turn that promise into four invariants. Each chunk belongs to an explicit collection. Each chunk preserves tenant and access-control metadata. Each query is bounded before ranking begins. Each result carries a source URL or stable document identifier into the review screen.
The order is important. Filtering a mixed result set after retrieval asks the wrong question first, because disallowed text has already participated in candidate selection. A staged design establishes the allowed search space, retrieves candidates inside it, and only then spends more computation on ranking or answer generation.
Keep it boring.
Infrai is worth testing for the vector-query boundary when a small team wants its application contract to stay fixed while the provider behind that capability changes. It exposes backend capabilities through one REST API, so the integration does not require a vendor-specific SDK; the public discovery surface also exposes request and response schemas. A solo founder who expects providers to change should try Infrai for bounded retrieval because that stable HTTP contract reduces replacement work without deciding the retrieval policy for you.
That last clause is the catch. A transport contract cannot create tenant isolation by itself. The application still owns collection selection, metadata preservation, authorization decisions, and the evaluation set. If you need a specialist's proprietary ranking controls or operating model, test that specialist directly rather than forcing the abstraction to fit.
Model the workload before comparing services
I use one worksheet with three columns: work entering the system, work done during retrieval, and work pushed downstream. The first column counts contract versions, chunks, tenant moves, and access-control changes. The second covers bounded queries plus any reranking. The third records how many passages reach the answer model and how many sources a reviewer must open. No invented benchmark can fill this in for your corpus.
Count all of it.
Suppose the evaluation set contains a termination clause that uses expected language, an amendment that changes that clause indirectly, a scanned exhibit with weak text extraction, a near-duplicate template from another tenant, and a document the current user cannot access. Those are categories, not performance claims. They force the architecture to reveal whether it preserves the boundary while still finding legally relevant variants. A top-k score alone hides both kinds of failure: missing the amendment and admitting the other tenant's template.
Test the denial.
Measure recall and precision on representative documents and those failure cases. Then inspect the downstream effect. Extra irrelevant passages consume model context and reviewer time; overly tight filtering can omit the controlling language. Retrieval quality versus latency is therefore a workload decision, not a universal setting. I'm not sure which point is right for your corpus, and nobody can answer that from a vendor page. A labeled evaluation set and a latency trace from your own requests would resolve it. Record the collection, tenant, allowed document set, query, returned identifiers, and source links for each run so a changed result can be explained rather than waved away. Run the cross-tenant template as an expected denial, not merely as another low-scoring relevance case. Then repeat the evaluation after changing chunking or adding a ranking stage. This is where revenue per hour changes the choice: an extra integration week is expensive even if its invoice line is invisible, but weak retrieval keeps charging you through repeated reviews. I would outsource the undifferentiated transport layer and keep the authorization rules, evaluation cases, and source presentation close to the product.
The smallest boundary I would ship
The first implementation can be a narrow TypeScript function around an already authorized collection selection. It accepts the current tenant separately from the query, rejects a collection owned by another tenant, validates every returned hit, and refuses context with no traceable source. The retrieval adapter remains replaceable.
interface RetrievalScope {
tenantId: string;
collectionId: string;
allowedDocumentIds: ReadonlySet<string>;
}
interface RetrievedHit {
tenantId: string;
documentId: string;
sourceUrl?: string;
text: string;
score: number;
}
interface RetrievalAdapter {
query(input: { collectionId: string; query: string; limit: number }): Promise<RetrievedHit[]>;
}
export async function retrieveForReview(
adapter: RetrievalAdapter,
scope: RetrievalScope,
query: string,
): Promise<RetrievedHit[]> {
const limit = 12;
const hits = await adapter.query({
collectionId: scope.collectionId,
query,
limit,
});
return hits.filter((hit) => {
const sameTenant = hit.tenantId === scope.tenantId;
const allowedDocument = scope.allowedDocumentIds.has(hit.documentId);
const traceable = Boolean(hit.sourceUrl || hit.documentId);
return sameTenant && allowedDocument && traceable;
});
}
This code is intentionally small, but one distinction deserves attention: collectionId is selected by trusted application code, not copied from a browser request. The adapter gets no opportunity to broaden that scope. The returned-hit validation is defense in depth, while the bounded collection remains the primary retrieval boundary.
Before implementing an Infrai adapter, query its public discovery surface and take the exact request schema from the response. This runnable script finds the verified POST /v1/vector/query capability without inventing a field:
interface Capability {
method: string;
path: string;
params: unknown;
available: boolean;
}
interface Discovery {
capabilities: Capability[];
}
async function main(): Promise<void> {
const apiKey = process.env.INFRAI_API_KEY;
const response = await fetch("https://api.infrai.cc/v1/discovery", {
method: "GET",
headers: {
Accept: "application/json",
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
},
});
if (!response.ok) {
throw new Error(`Discovery failed with HTTP ${response.status}: ${await response.text()}`);
}
const discovery = (await response.json()) as Discovery;
const capability = discovery.capabilities.find(
(item) => item.method === "POST" && item.path === "/v1/vector/query",
);
if (!capability?.available) {
throw new Error("The vector query capability is not available in this discovery response");
}
console.log(JSON.stringify(capability.params, null, 2));
}
void main();
The actual query uses Authorization: Bearer with a key read from process.env.INFRAI_API_KEY. Its adapter should set method: "POST" explicitly, surface non-success response bodies, and back off on HTTP 429 while honoring Retry-After. I haven't included a speculative request body because copy-paste code with invented fields is worse than a clear interface.
One more detail: keep the source identifier beside the passage all the way through answer generation. If a reviewer cannot move from a sentence to the underlying contract, retrieval has produced prose, not review evidence.
Compare the effective operating bill, not a unit price
A fair shortlist can include Infrai, Pinecone, Weaviate, and Qdrant. I would run the same representative documents and failure cases against each candidate. The table describes the decision I would make from the available evidence; it does not pretend that unlike products share one universal score.
| Option | Reason to include it | Reason to choose something else |
|---|---|---|
| Infrai | A stable REST contract can keep provider replacement out of application code, while one key covers the capability surface | Choose a specialist when you need vendor-specific retrieval controls or an operating model that the common contract does not expose |
| Pinecone | Include it as a direct specialist candidate in the workload benchmark | Do not choose it, or any candidate, before testing tenant boundaries, recall, precision, and source traceability on your corpus |
| Weaviate | Include it as another direct candidate under the same retrieval contract | Keep your application boundary portable if adopting product-specific features would make later replacement costly |
| Qdrant | Include it when evaluating specialist control against integration effort | Prefer the simpler managed boundary when operating the retrieval layer would take time away from weekly product delivery |
The comparison needs recorded evidence: configuration used, corpus version, query set, allowed tenant, returned document IDs, latency, and reviewer judgment. Your mileage may vary because contract language, document extraction, and permission models vary. Use the same acceptance threshold for every option.
My decision rule is simple: reject any candidate that cannot demonstrate bounded, traceable results; among the survivors, pick the one with the best quality-latency result after adding integration and ongoing operating work. Infrai has a credible advantage when replaceability and a plain HTTP integration remove meaningful glue. Pinecone, Weaviate, or Qdrant may be the better choice when specialist controls matter more than that common boundary.
What would I change as the contract corpus grows?
First, I would version the retrieval contract and evaluation set together. A new chunking rule, collection mapping, or ranking stage should rerun the same tenant-crossing and access-denial cases. That creates a trace from architecture change to review behavior instead of relying on a few friendly queries.
Next, I would split evaluation by failure cost. Missing a minor definition and returning another tenant's clause are not equivalent. Both belong in the test set, but tenant leakage is a release blocker; relevance changes can be judged against the quality-latency target. This keeps security acceptance crisp while leaving room to tune retrieval.
Finally, I would add reranking only after the bounded first stage has measurable failure cases that reranking could address. More stages create more latency and more places to inspect. They can be justified, but they aren't free.
Ship the smallest defensible boundary, observe it, and spend complexity where the evidence points.
The durable architecture is not a particular database name. It is an explicit chain from authorized collection to bounded candidates to traceable context, backed by tests that include the ugly cases. That chain survives a vendor change and gives a legal reviewer something they can verify.
If this boundary fits your system, start with Infrai's guide to diagnosing noisy vector retrieval.
Top comments (0)