Add multi-tenant protocol with isolation levels and quota management#82
Add multi-tenant protocol with isolation levels and quota management#82
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Implements a multi-tenant system protocol so SaaS deployments can declare how tenants are isolated and what quotas apply, with corresponding JSON Schemas and reference docs.
Changes:
- Added
TenantIsolationLevel,TenantQuotaSchema, andTenantSchemaZod definitions plus inferred types insrc/system/tenant.zod.ts. - Added comprehensive Vitest coverage for tenant isolation, quotas, and customization behaviors in
src/system/tenant.test.ts, and exported the new schema fromsrc/system/index.ts. - Introduced JSON Schema artifacts (
Tenant.json,TenantQuota.json,TenantIsolationLevel.json) and reference documentation pages for these types undercontent/docs/references/system.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/spec/src/system/tenant.zod.ts |
Defines the core tenant, isolation level enum, and quota schemas following existing Zod-first, camelCase/snake_case conventions. |
packages/spec/src/system/tenant.test.ts |
Adds unit tests validating allowed/denied isolation levels, quota constraints, and required tenant properties. |
packages/spec/src/system/index.ts |
Re-exports the new tenant schema module from the system barrel file. |
packages/spec/json-schema/TenantQuota.json |
JSON Schema for the tenant quota object, matching the Zod quota fields and constraints. |
packages/spec/json-schema/TenantIsolationLevel.json |
JSON Schema enum for tenant isolation levels aligning with the Zod enum. |
packages/spec/json-schema/Tenant.json |
JSON Schema for the tenant object, including isolation level, customizations, and quotas. |
content/docs/references/system/TenantQuota.mdx |
Reference doc for the TenantQuota schema (note: table header currently uses an extra leading pipe and should be normalized). |
content/docs/references/system/TenantIsolationLevel.mdx |
Reference doc documenting the allowed tenant isolation level values. |
content/docs/references/system/Tenant.mdx |
Reference doc for the Tenant schema (note: properties table uses ` |
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | |
There was a problem hiding this comment.
The markdown table header has an extra leading pipe (|| Property / || :---), which will render an empty first column and is inconsistent with other reference docs (e.g., Organization.mdx). Drop the extra pipe so the header rows start with a single | to match the established table format.
| | Property | Type | Required | Description | | ||
| | :--- | :--- | :--- | :--- | |
There was a problem hiding this comment.
The properties table starts each row with a double pipe (|| ...), which introduces an empty column and differs from the standard reference-table format used elsewhere (e.g., Organization.mdx). Please change these rows to start with a single | so the table renders correctly and consistently.
Implements tenant protocol for SaaS deployments with configurable data isolation strategies and resource quotas.
Changes
src/system/tenant.zod.ts: Core tenant schema with three isolation modesshared_schema: Row-level isolation (single DB, single schema)isolated_schema: Schema-per-tenant (single DB, separate schemas)isolated_db: Database-per-tenant (maximum isolation)Quota management:
maxUsers,maxStorage(bytes),apiRateLimit(requests/min)Customization support: Arbitrary tenant-specific configuration via
customizationsrecordUsage
Follows established patterns: Zod-first definitions, camelCase config keys, snake_case enum values, inferred TypeScript types.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.