Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Part A: Turso multi-tenant router schema, platform API contract, SQLite type mappings - Part B: Tenant provisioning schema, extended TenantSchema with Turso fields, provisioning service contract - Part C: Deploy bundle schema, schema diff service contract, deploy pipeline service contract - Part D: Tenant runtime context schema, tenant router contract, quota enforcement schemas - Part E: App install bundle schema, app lifecycle service contract - All index exports updated (data, system, contracts) - 66 new tests across 4 test files (225 total test files, 6341 tests passing) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 仔细评估是否已完成所有开发需求 |
…Schema, QuotaEnforcementResult, TenantRuntimeContext Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
完成了所有需求的逐项评估,以下是对照 Issue 任务清单的完成状态: Part A: Turso Driver Protocol ✅
Part B: Tenant Provisioning ✅
Part C: Metadata-Driven Deployment ✅
Part D: Tenant-Aware Runtime ✅
Part E: App Installation ✅
All 225 test files / 6363 tests passing. Roadmap updated. |
There was a problem hiding this comment.
Pull request overview
This PR implements a comprehensive Cloud-Native Multi-Tenant Provisioning Protocol for ObjectStack, enabling the "Register → Instant ObjectOS" architecture with Turso DB-per-Tenant, metadata-driven deployment, and shared compute with isolated data.
Changes:
- Added Turso multi-tenant driver protocol with DB-per-Tenant configuration, lifecycle hooks, and group management schemas
- Created tenant provisioning protocol with request/result schemas, status tracking, and plan/region enums
- Implemented metadata-driven deployment bundle protocol with schema diff, migration plans, and validation
- Added app installation protocol for marketplace apps with compatibility checking and install workflows
- Extended tenant, kernel context, and SQL driver schemas to support multi-tenant provisioning
- Defined 6 new service contracts (ITursoPlatformService, IProvisioningService, ISchemaDiffService, IDeployPipelineService, ITenantRouter, IAppLifecycleService)
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
packages/spec/src/system/tenant.zod.ts |
Extended TenantSchema with databaseProvider, connectionConfig, provisioningStatus, plan fields; added TenantUsageSchema and QuotaEnforcementResultSchema; expanded TenantQuotaSchema with deployment quotas |
packages/spec/src/system/tenant.test.ts |
Added 185 lines of comprehensive tests for new tenant schema extensions |
packages/spec/src/system/provisioning.zod.ts |
New file defining tenant provisioning protocol with status/plan/region enums, provisioning steps, and request/result schemas |
packages/spec/src/system/provisioning.test.ts |
New file with 173 lines of tests covering all provisioning schemas |
packages/spec/src/system/deploy-bundle.zod.ts |
New file defining deployment protocol with deploy status, schema diff, migration plans, validation, and bundle schemas |
packages/spec/src/system/deploy-bundle.test.ts |
New file with 201 lines of tests for deployment bundle schemas |
packages/spec/src/system/app-install.zod.ts |
New file defining app installation protocol with manifest, compatibility check, and install request/result schemas |
packages/spec/src/system/app-install.test.ts |
New file with 167 lines of tests for app installation schemas |
packages/spec/src/system/index.ts |
Added exports for provisioning, deploy-bundle, and app-install modules |
packages/spec/src/kernel/context.zod.ts |
Extended KernelContextSchema with TenantRuntimeContextSchema for tenant-aware runtime context |
packages/spec/src/kernel/context.test.ts |
Added 72 lines of tests for TenantRuntimeContextSchema |
packages/spec/src/data/index.ts |
Added export for turso-multi-tenant driver |
packages/spec/src/data/driver/turso-multi-tenant.zod.ts |
New file defining Turso multi-tenant router configuration with resolver strategies, group config, and lifecycle hooks |
packages/spec/src/data/driver/turso-multi-tenant.test.ts |
New file with 183 lines of comprehensive tests for Turso driver schemas |
packages/spec/src/data/driver-sql.zod.ts |
Added SQLiteDataTypeMappingDefaults and SQLiteAlterTableLimitations constants for SQLite dialect support |
packages/spec/src/contracts/turso-platform.ts |
New contract defining ITursoPlatformService interface for Turso Platform API operations |
packages/spec/src/contracts/provisioning-service.ts |
New contract defining IProvisioningService interface for tenant lifecycle management |
packages/spec/src/contracts/schema-diff-service.ts |
New contract defining ISchemaDiffService interface for schema introspection and migration generation |
packages/spec/src/contracts/deploy-pipeline-service.ts |
New contract defining IDeployPipelineService interface for metadata-driven deployments |
packages/spec/src/contracts/tenant-router.ts |
New contract defining ITenantRouter interface for tenant-aware request routing |
packages/spec/src/contracts/app-lifecycle-service.ts |
New contract defining IAppLifecycleService interface for app installation/upgrade/uninstall |
packages/spec/src/contracts/index.ts |
Added exports for all new provisioning and deployment contracts |
docs/NEXT_STEP.md |
Updated checklist to mark deployment protocol and service contracts as complete |
| maxStorage: z.number().int().positive().optional().describe('Maximum storage in bytes'), | ||
|
|
||
| /** | ||
| * API rate limit (requests per minute) | ||
| */ | ||
| apiRateLimit: z.number().int().positive().optional().describe('API requests per minute'), | ||
|
|
||
| /** | ||
| * Maximum number of custom objects the tenant can create | ||
| */ | ||
| maxObjects: z.number().int().positive().optional().describe('Maximum number of custom objects'), | ||
|
|
||
| /** | ||
| * Maximum records per object/table | ||
| */ | ||
| maxRecordsPerObject: z.number().int().positive().optional().describe('Maximum records per object'), | ||
|
|
||
| /** | ||
| * Maximum deployments allowed per day | ||
| */ | ||
| maxDeploymentsPerDay: z.number().int().positive().optional().describe('Maximum deployments per day'), | ||
|
|
||
| /** | ||
| * Maximum storage in bytes | ||
| */ | ||
| maxStorageBytes: z.number().int().positive().optional().describe('Maximum storage in bytes'), |
There was a problem hiding this comment.
There's a redundancy in TenantQuotaSchema: both maxStorage (line 70) and maxStorageBytes (line 95) represent storage limits in bytes. Consider removing the deprecated maxStorage field or clarifying their difference in documentation if they serve different purposes.
| export const SQLiteDataTypeMappingDefaults: DataTypeMapping = { | ||
| text: 'TEXT', | ||
| number: 'REAL', | ||
| boolean: 'INTEGER', | ||
| date: 'TEXT', | ||
| datetime: 'TEXT', | ||
| json: 'TEXT', | ||
| uuid: 'TEXT', | ||
| binary: 'BLOB', | ||
| }; | ||
|
|
||
| /** | ||
| * SQLite ALTER TABLE Limitations. | ||
| * | ||
| * SQLite has limited ALTER TABLE support compared to other SQL databases. | ||
| * This constant documents the known limitations that affect migration planning. | ||
| * The schema diff service must use the "table rebuild" strategy for operations | ||
| * that SQLite cannot perform natively. | ||
| * | ||
| * @see https://www.sqlite.org/lang_altertable.html | ||
| */ | ||
| export const SQLiteAlterTableLimitations = { | ||
| /** SQLite supports ADD COLUMN */ | ||
| supportsAddColumn: true, | ||
| /** SQLite supports RENAME COLUMN (3.25.0+) */ | ||
| supportsRenameColumn: true, | ||
| /** SQLite supports DROP COLUMN (3.35.0+) */ | ||
| supportsDropColumn: true, | ||
| /** SQLite does NOT support MODIFY/ALTER COLUMN type */ | ||
| supportsModifyColumn: false, | ||
| /** SQLite does NOT support adding constraints to existing columns */ | ||
| supportsAddConstraint: false, | ||
| /** | ||
| * When an unsupported alteration is needed, the migration planner | ||
| * must use the 12-step table rebuild strategy: | ||
| * 1. CREATE new table with desired schema | ||
| * 2. Copy data from old table | ||
| * 3. DROP old table | ||
| * 4. RENAME new table to old name | ||
| */ | ||
| rebuildStrategy: 'create_copy_drop_rename', | ||
| } as const; |
There was a problem hiding this comment.
The new SQLite-specific constants SQLiteDataTypeMappingDefaults and SQLiteAlterTableLimitations lack test coverage. Add tests to verify that SQLiteDataTypeMappingDefaults conforms to the DataTypeMapping type and that SQLiteAlterTableLimitations has the expected structure and values.
| provisioningStatus: z.enum([ | ||
| 'provisioning', 'active', 'suspended', 'failed', 'destroying', | ||
| ]).optional().describe('Current provisioning lifecycle status'), | ||
|
|
||
| /** | ||
| * Tenant subscription plan | ||
| */ | ||
| plan: z.enum(['free', 'pro', 'enterprise']).optional().describe('Subscription plan'), |
There was a problem hiding this comment.
The tenant plan enum is defined inline here instead of reusing TenantPlanSchema from provisioning.zod.ts. For consistency and DRY principles, consider importing and using TenantPlanSchema instead of duplicating the enum definition. The same applies to provisioningStatus which duplicates TenantProvisioningStatusEnum.
| tenantId: z.string().min(1).describe('Resolved tenant identifier'), | ||
|
|
||
| /** Tenant subscription plan */ | ||
| tenantPlan: z.enum(['free', 'pro', 'enterprise']).describe('Tenant subscription plan'), |
There was a problem hiding this comment.
The tenant plan enum is defined inline here instead of reusing TenantPlanSchema from provisioning.zod.ts. For consistency and DRY principles, import TenantPlanSchema and use it here: tenantPlan: TenantPlanSchema.describe('Tenant subscription plan').
| tenantPlan: z.enum(['free', 'pro', 'enterprise']).describe('Tenant subscription plan'), | ||
|
|
||
| /** Tenant deployment region */ | ||
| tenantRegion: z.string().min(1).describe('Tenant deployment region'), |
There was a problem hiding this comment.
The tenantRegion field is defined as a plain string (z.string().min(1)) instead of using the TenantRegionSchema enum from provisioning.zod.ts. For type safety and validation consistency, consider using TenantRegionSchema to ensure only valid regions are accepted.
Protocol-level schemas, contracts, and driver specs for the "Register → Instant ObjectOS" architecture: Turso DB-per-Tenant, metadata-driven deployment, shared compute with isolated data.
Turso Driver Protocol
data/driver/turso-multi-tenant.zod.ts—TursoMultiTenantConfigSchema(URL template, group auth, resolver strategy),TursoGroupSchema(region, replicas, schema DB),TenantDatabaseLifecycleSchema(create/delete/suspend hooks)contracts/turso-platform.ts—ITursoPlatformServiceinterface: createDatabase, deleteDatabase, listDatabases, createToken, revokeTokensdata/driver-sql.zod.ts—SQLiteDataTypeMappingDefaultsconstant,SQLiteAlterTableLimitations(documents table rebuild strategy)Tenant Provisioning
system/provisioning.zod.ts—TenantProvisioningRequestSchema(orgId, plan, region),TenantProvisioningResultSchema(tenantId, connectionUrl, steps), status/plan/region enums,ProvisioningStepSchemasystem/tenant.zod.ts— ExtendedTenantSchemawithdatabaseProvider(turso|postgres|memory),connectionConfig,provisioningStatus,plan. AddedTenantUsageSchema,QuotaEnforcementResultSchema, expandedTenantQuotaSchemawithmaxObjects,maxRecordsPerObject,maxDeploymentsPerDay,maxStorageBytescontracts/provisioning-service.ts—IProvisioningService: provision, suspend, resume, destroy, migrate planMetadata-Driven Deployment
system/deploy-bundle.zod.ts—DeployBundleSchema,DeployManifestSchema,DeployDiffSchema,MigrationPlanSchema,DeployValidationResultSchema,DeployStatusEnumcontracts/schema-diff-service.ts—ISchemaDiffService: introspect → diff → generateMigrations → applyMigrationscontracts/deploy-pipeline-service.ts—IDeployPipelineService: validateBundle → planDeployment → executeDeployment → rollbackDeploymentTenant-Aware Runtime
kernel/context.zod.ts—TenantRuntimeContextSchemaextendsKernelContextSchemawithtenantId,tenantPlan,tenantRegion,tenantDbUrlcontracts/tenant-router.ts—ITenantRouter: resolveTenant, getTenantClient, invalidateCacheApp Installation
system/app-install.zod.ts—AppManifestSchema(snake_case name, version, objects, dependencies),AppCompatibilityCheckSchema,AppInstallRequestSchema,AppInstallResultSchemacontracts/app-lifecycle-service.ts—IAppLifecycleService: checkCompatibility, installApp, uninstallApp, upgradeApp88 new tests across 6 test files (4 new + 2 updated). All 225 test files / 6363 tests pass.
Original prompt
This section details on the original issue you should resolve
<issue_title>🏗️ [Protocol] Cloud-Native Multi-Tenant Provisioning Protocol (Turso + Metadata Pipeline)</issue_title>
<issue_description>
Summary
Define and implement the protocol-level schemas, contracts, and driver specifications required to support the "注册即开通" (Register → Instant ObjectOS) architecture: Turso DB-per-Tenant + Metadata-Driven Deployment Pipeline + Shared Compute with Isolated Data.
Motivation
ObjectStack Cloud needs a complete protocol layer to support:
This issue covers protocol and spec changes only (Zod schemas, TypeScript types, contracts). The runtime implementation is tracked in a separate issue.
Architecture Decision Record
isolated_dbTenantIsolationLevelintenant.zod.tsTask Breakdown
Part A: Turso Driver Protocol Completion (spec)
Status: Phase 0 (Schema) ✅ Done → Phase A (Core Driver) 🔴 Needs Implementation
A1. Turso Multi-Tenant Router Schema —
packages/spec/src/data/driver/turso-multi-tenant.zod.tsTursoMultiTenantConfigSchemawithurlTemplate,groupAuthToken,tenantResolverStrategyTenantDatabaseLifecycleSchemawithonTenantCreate,onTenantDelete,onTenantSuspendhooksTursoGroupSchemafor Turso Database Group configuration (region, primary location)packages/spec/src/data/index.tsexportspackages/spec/src/data/driver/turso-multi-tenant.test.tsA2. Turso Platform API Contract —
packages/spec/src/contracts/turso-platform.tsITursoPlatformServiceinterface:createDatabase(),deleteDatabase(),listDatabases(),createToken(),revokeToken()TursoDatabaseInforesponse schemaTursoTokenScopeenum (full-access,read-only)@objectstack/driver-tursopackageA3. SQLite Dialect for SQL Compiler — Extend
packages/spec/src/data/driver-sql.zod.tsSQLDialectSchemaalready includes'sqlite'✅ (confirmed)SQLiteDataTypeMappingDefaultsconstant with TEXT/REAL/INTEGER/BLOB mappingsSQLiteAlterTableLimitationsdocumentation constant (no MODIFY COLUMN, table rebuild strategy)Part B: Tenant Provisioning Protocol
B1. Tenant Provisioning Schema —
packages/spec/src/system/provisioning.zod.ts(NEW FILE)packages/spec/src/system/provisioning.test.tspackages/spec/src/system/index.tsB2. Extend TenantSchema for Turso —
packages/spec/src/system/tenant.zod.tsdatabaseProviderfield toTenantSchema:z.enum(['turso', 'postgres', 'memory'])connectionConfigfield:z.object({ url, authToken, group })(encrypted at rest)provisioningStatusfield usingTenantProvisioningStatusEnumplanfield referencingTenantPlanSchemaB3. Provisioning Service Contract —
packages/spec/src/contracts/provisioning-service.ts(NEW FILE)💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.