Skip to content

Multi-Tenant Isolation & Data Classifications

Enterprise SaaS and regulated healthcare systems must isolate organization records strictly across every query and mutation while tagging personal and protected fields for masking, consent governance, and test anonymization.


1. MultiTenant vs GlobalMaster Scoping

Attach traits directly in Object Browser → Traits (🧩) or on entity cards in Diagram View:

Trait Tenant Scoping Behavior Common Domain Uses
MultiTenant Injects indexed tenantId (String) into the schema and constrains every generated read (findMany, findOne, findView) and mutation (update, delete) to req.user.tenantId. Operational records: Customer, WorkOrder, FieldAsset, Patient, Appointment, MedicalRecord
GlobalMaster Shares canonical cross-tenant lookup data readably while preserving auditability and role write guards. Standard code sets, tax jurisdictions, SNOMED / tariff reference tables

Every compiled endpoint guarded by MultiTenant merges { id, tenantId: req.user.tenantId } into Prisma where clauses (using findFirst, update, or delete), eliminating cross-tenant identifier enumeration by construction.


2. Five-Tier Data Sensitivity Classification

Every entity attribute carries an explicit privacy classification tier used across the RBAC Matrix, API serializers, and Scenario PII Vault:

Tier Intent & Policy Effect Example Attributes
Public Non-sensitive catalog or status fields safe for broad display code, status, durationMinutes
Internal Operational metadata restricted to authenticated workspace users slaTargetHours, priority, assignedRegion
PII Personally identifiable contact or identity data subject to GDPR masking & PII Vault scrubbing primaryContactEmail, nhsNumber, firstName, lastName, dateOfBirth
Confidential Restricted commercial, credential, or non-public diagnosis values primarySnomedCode, treatmentPlan, systolicBP, siteAccessPin
ePHI Electronic Protected Health Information triggering mandatory unseal checks (reveal_sensitive) and HIPAA read/write audit events presentingComplaint, clinicalSummary

When an attribute combines classification: PII, Confidential, or ePHI with role restrictions, users holding read without <Entity>.reveal_sensitive receive masked placeholders while authorized roles unseal the plaintext cleanly.


3. Automated PII Vault Scrubbing for Safe Environments

During Scenario snapshots and environment dataset captures, attributes marked classification: PII, Confidential, or ePHI are detected automatically and redacted into deterministic synthetic values inside non-production snapshots. Real patient identifiers and customer contact records remain isolated to encrypted production storage while staging and test suites retain valid schema shapes.


4. Guided Example — Tenant Isolation & Privacy Classifications

Security & Operations · Guide 2 of 5
MultiTenant Query Scoping, Sensitivity Tiers & Disclosure Controls
Previously in this build: In Guide 1, OperationsManager received full Customer visibility while Dispatcher stayed masked on sensitive Customer fields.
✅ Checkpoint:Every Customer lookup and mutation scopes cleanly by req.user.tenantId and classifies PII vs Confidential attributes.
Primary TrackAttach MultiTenant to Customer, WorkOrder, FieldAsset, and Technician; mark Customer.primaryContactEmail as PII and Customer.siteAccessPin as Confidential; and verify compiled tenantId scoping inside CustomerController.
  1. Attach MultiTenant Across Operational Entities: Confirm Customer carries the MultiTenant trait stack alongside SoftDelete and Auditable so every customer account belongs strictly to an organization tenantId.
  2. Classify Contact & Site Credentials: Verify Customer.primaryContactEmail carries classification: PII for contact masking and GDPR scrubbing, while Customer.siteAccessPin carries classification: Confidential with encryption enabled.
  3. Inspect Compiled Tenant Filtering on findOne: Expand Under the Hood below to verify CustomerController builds whereClause.tenantId = req.user.tenantId before querying Prisma and unsealing encrypted attributes.