DEV Community

Cover image for Multi-Tenant Semantic Isolation: Enforcing Tenant Boundaries at Compile Time
Yogendra Sharma
Yogendra Sharma

Posted on Originally published at colrows.com

Multi-Tenant Semantic Isolation: Enforcing Tenant Boundaries at Compile Time

We've been building multi-tenant AI systems and hit a wall most platforms quietly ignore.

Data can be isolated. Meaning cannot — not by the usual mechanisms.

The problem in one sentence

Two tenants define revenue differently. Both are correct. Your semantic layer has to be right twice, simultaneously, without either tenant's definition leaking into the other's answers.

Row-level security doesn't help here. It isolates rows. This is a collision in the definition layer, above the data.

Where naive designs break

Approach Failure
One shared graph, tenant filter Tenant A's definition resolves for Tenant B
One graph per tenant Maintenance cost multiplies by tenant count
Namespace prefixes Shared concepts get duplicated and drift
Isolation at the API layer Resolution already happened underneath

Multi-scope resolution

The workable answer is to make scope a first-class dimension of the graph itself: global → datastore → persona → user.

A concept resolves by walking that chain and taking the most specific definition available. Revenue might be defined globally, overridden for a datastore, refined for a persona. Tenant boundaries become a scope level rather than a deployment decision.

Two properties fall out of that:

  • Compile-time enforcement — an unauthorised cross-tenant resolution fails to compile rather than returning filtered rows
  • Shared maintenance — a global improvement propagates to every tenant that hasn't overridden it, so you're not maintaining N graphs

Why this matters beyond SaaS

Any organisation with distinct legal entities, regional definitions, or acquired subsidiaries has the same problem internally. "One version of the truth" is usually wrong — you need one version per scope, resolved deterministically, with the boundaries provable.


The full breakdown — the scope resolution model, the compile-time isolation guarantees, and the tenancy architecture — is here:

👉 Multi-Tenant Semantic Isolation: Enforcing Tenant Boundaries at Compile Time


Originally published at colrows.com/blogs/multi-tenant-semantic-isolation

Top comments (0)