KatInterview

Tenant-Safe Next-File Suggestions with Live Permission Checks

Machine LearningModel answer
MediumModel answerMachine Learningrecommender-systemsmulti-tenancyaccess-control

Last updated

Design a low-latency recommender that proposes the next file a user will open while keeping each company's data isolated and respecting constantly changing file permissions.

Scenario

A cloud document platform serves thousands of customer companies (tenants). It wants a "you might open this next" feature that uses each user's own activity and broader usage patterns to suggest files.

The hard rule is tenant isolation: a user at one company must never see a suggestion that comes from another company, even if that file would otherwise look popular or relevant. Within a company, a user may only be shown files they are currently allowed to view, and those permissions change often as people join or leave folders and groups.

Requirements

  1. Data isolation. Training data and the context used at inference time must not cross tenant boundaries.
  2. Permission enforcement. Only files the user can currently view may be suggested.
  3. Latency. Top-k results must come back in under 100 ms.
  4. Scale. Millions of users across thousands of tenants, with very uneven tenant sizes.

Constraints

  • No information may leak between tenants through model gradients or shared embeddings.
  • Permission checks should happen as close to the ranking stage as practical, so that few invalid suggestions are produced.

What to deliver

  1. A high-level architecture for training and for serving.
  2. A strategy for enforcing permissions inside the recommendation pipeline.
  3. A plan for cold start (new files, and optionally new users and tenants) that keeps tenant isolation intact.

State your scale assumptions and discuss the trade-offs of the choices you make.

Hints

Hint 1

Write down the invariants first (no cross-tenant candidates, no cross-tenant learned parameters, every returned file is permitted at serve time), then ask which components could break each one.

Hint 2

Consider a hybrid model: a shared ranker that only sees behavior-style features with no IDs or content, plus per-tenant embeddings and indexes for anything that carries identity.

Hint 3

Compare filtering permissions before retrieval, after ranking, and between retrieval and ranking. Think about what each costs in latency and in wasted ranking work, and about a final cheap revalidation of the top-k.

Hint 4

For cold start, look for signals available at creation time: folder, creator, who it was shared with, and content vectors from a frozen encoder that was never trained on tenant data.