Hub Protocol: Add API contracts, federation, and security protocols#469
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
| import { | ||
| // Space Management | ||
| CreateSpaceRequest, | ||
| SpaceResponse, | ||
| ListSpacesResponse, | ||
|
|
||
| // Tenant Management | ||
| CreateTenantRequest, | ||
| TenantResponse, | ||
|
|
||
| // Plugin Registry | ||
| PublishPluginRequest, | ||
| PluginResponse, | ||
| SearchPluginsResponse, | ||
|
|
||
| // License Management | ||
| IssueLicenseRequest, | ||
| LicenseResponse, | ||
| ValidateLicenseResponse, | ||
|
|
||
| // Composer Service | ||
| CompileManifestRequest, | ||
| CompileManifestResponse, | ||
|
|
||
| // Health & Monitoring | ||
| HubHealthResponse, | ||
| HubMetricsResponse, | ||
| } from '@objectstack/spec/api'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix unused imports, remove only the specific identifiers that are not referenced anywhere in the file, leaving the rest of the import structure intact. This avoids any behavior changes while cleaning up the code.
Concretely, in examples/basic/hub-management-example.ts, adjust the @objectstack/spec/api import block: delete CreateTenantRequest, TenantResponse, and PluginResponse from the named import list, keeping formatting and comments for other sections the same. No additional methods, definitions, or imports are required.
| @@ -20,12 +20,10 @@ | ||
| ListSpacesResponse, | ||
|
|
||
| // Tenant Management | ||
| CreateTenantRequest, | ||
| TenantResponse, | ||
| // (no tenant-specific types used in this example yet) | ||
|
|
||
| // Plugin Registry | ||
| PublishPluginRequest, | ||
| PluginResponse, | ||
| SearchPluginsResponse, | ||
|
|
||
| // License Management |
| import { | ||
| // Federation | ||
| Region, | ||
| FederationTopology, | ||
| TenantPlacementPolicy, | ||
|
|
||
| // Security | ||
| SecurityScanResult, | ||
| SecurityPolicy, | ||
| DependencyResolutionResult, | ||
| SBOM, | ||
| PluginProvenance, | ||
| PluginTrustScore, | ||
| } from '@objectstack/spec/hub'; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
In general, to fix an unused import, remove it from the import list (or add code that actually uses it, if it was intended to be used). This keeps the codebase clean and avoids misleading readers about required dependencies.
For this specific file, the best fix without changing functionality is to remove Region from the import list from @objectstack/spec/hub on lines 47–58. No other code changes are needed, as the unused symbol is not referenced elsewhere in the shown snippet. Concretely, in examples/basic/hub-management-example.ts, edit the import block starting at line 45 so that the comment // Federation is followed directly by FederationTopology and TenantPlacementPolicy, omitting Region. No additional methods, imports, or definitions are required.
| @@ -44,7 +44,6 @@ | ||
|
|
||
| import { | ||
| // Federation | ||
| Region, | ||
| FederationTopology, | ||
| TenantPlacementPolicy, | ||
|
|
There was a problem hiding this comment.
Pull request overview
This pull request adds comprehensive Hub protocol enhancements to ObjectStack, introducing API contracts, multi-region federation, and plugin security infrastructure for managing tenants, plugins, and workspaces at scale.
Changes:
- Complete REST API specifications for Hub management operations (spaces, tenants, plugins, licenses, composer, health monitoring)
- Multi-region federation protocol supporting global deployments with data residency compliance (GDPR, HIPAA, SOC2)
- Plugin security and supply chain protocols including vulnerability scanning, dependency resolution, SBOM generation, provenance tracking, and trust scoring
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/api/hub.zod.ts | Comprehensive Hub API contracts with request/response schemas for all management operations |
| packages/spec/src/api/hub.test.ts | Test coverage for Hub API protocols |
| packages/spec/src/api/index.ts | Export Hub API protocols |
| packages/spec/src/hub/hub-federation.zod.ts | Multi-region federation protocol with regions, hub instances, tenant placement policies, and replication |
| packages/spec/src/hub/hub-federation.test.ts | Test coverage for federation protocol |
| packages/spec/src/hub/plugin-security.zod.ts | Plugin security protocol with vulnerability scanning, dependency resolution, SBOM, provenance, and trust scoring |
| packages/spec/src/hub/plugin-security.test.ts | Test coverage for security protocol |
| packages/spec/src/hub/index.ts | Export enhanced Hub protocols |
| examples/basic/hub-management-example.ts | Comprehensive examples demonstrating Hub protocol usage |
| HUB_PROTOCOL_SUMMARY.md | Executive summary and documentation of Hub protocol enhancements |
| HUB_PROTOCOL_DEVELOPMENT_PLAN.md | Detailed development plan and implementation roadmap |
| export const HubMetricsResponseSchema = z.object({ | ||
| metrics: z.object({ | ||
| spaces: z.object({ | ||
| total: z.number().int(), | ||
| active: z.number().int(), | ||
| created_last_30d: z.number().int().optional(), | ||
| }).optional(), | ||
| tenants: z.object({ | ||
| total: z.number().int(), | ||
| active: z.number().int(), | ||
| }).optional(), | ||
| plugins: z.object({ | ||
| total: z.number().int(), | ||
| published_last_30d: z.number().int().optional(), | ||
| total_downloads: z.number().int().optional(), | ||
| }).optional(), | ||
| api: z.object({ | ||
| requests_per_minute: z.number(), | ||
| avg_response_time: z.number().describe('Milliseconds'), | ||
| error_rate: z.number().min(0).max(1), | ||
| }).optional(), | ||
| }), | ||
| timestamp: z.string().datetime(), | ||
| }); |
There was a problem hiding this comment.
Schema property names should use camelCase according to the coding guidelines. The following properties use snake_case instead:
created_last_30dshould becreatedLast30dpublished_last_30dshould bepublishedLast30dtotal_downloadsshould betotalDownloadsrequests_per_minuteshould berequestsPerMinuteavg_response_timeshould beavgResponseTimeerror_rateshould beerrorRate
The coding guideline states: "Configuration Keys (TS Props): camelCase (e.g., maxLength, referenceFilters)" while "Machine Names (Data Values): snake_case (e.g., name: 'first_name', object: 'project_task')". These are configuration keys in a TypeScript schema, not machine name data values.
| export const hubMetricsExample: HubMetricsResponse = { | ||
| metrics: { | ||
| spaces: { | ||
| total: 2450, | ||
| active: 1980, | ||
| created_last_30d: 125, | ||
| }, | ||
| tenants: { | ||
| total: 580, | ||
| active: 485, | ||
| }, | ||
| plugins: { | ||
| total: 342, | ||
| published_last_30d: 18, | ||
| total_downloads: 1245678, | ||
| }, | ||
| api: { | ||
| requests_per_minute: 1250, | ||
| avg_response_time: 85, | ||
| error_rate: 0.0012, | ||
| }, | ||
| }, | ||
| timestamp: '2024-01-15T12:00:00Z', | ||
| }; |
There was a problem hiding this comment.
Example property names should use camelCase to match the schema. The following properties use snake_case instead:
created_last_30dshould becreatedLast30dpublished_last_30dshould bepublishedLast30dtotal_downloadsshould betotalDownloadsrequests_per_minuteshould berequestsPerMinuteavg_response_timeshould beavgResponseTimeerror_rateshould beerrorRate
The coding guideline states: "Configuration Keys (TS Props): camelCase (e.g., maxLength, referenceFilters)"
| it('should validate HubMetricsResponse', () => { | ||
| const validResponse = { | ||
| metrics: { | ||
| spaces: { | ||
| total: 1250, | ||
| active: 980, | ||
| created_last_30d: 45, | ||
| }, | ||
| tenants: { | ||
| total: 320, | ||
| active: 285, | ||
| }, | ||
| plugins: { | ||
| total: 156, | ||
| published_last_30d: 8, | ||
| total_downloads: 456789, | ||
| }, | ||
| api: { | ||
| requests_per_minute: 850, | ||
| avg_response_time: 125, | ||
| error_rate: 0.002, | ||
| }, | ||
| }, | ||
| timestamp: '2024-01-01T12:00:00Z', | ||
| }; |
There was a problem hiding this comment.
Test data property names should use camelCase to match the schema. The following properties use snake_case instead:
created_last_30dshould becreatedLast30dpublished_last_30dshould bepublishedLast30dtotal_downloadsshould betotalDownloadsrequests_per_minuteshould berequestsPerMinuteavg_response_timeshould beavgResponseTimeerror_rateshould beerrorRate
The coding guideline states: "Configuration Keys (TS Props): camelCase (e.g., maxLength, referenceFilters)"
| import { | ||
| // Space Management | ||
| CreateSpaceRequest, | ||
| SpaceResponse, | ||
| ListSpacesResponse, | ||
|
|
||
| // Tenant Management | ||
| CreateTenantRequest, | ||
| TenantResponse, | ||
|
|
||
| // Plugin Registry | ||
| PublishPluginRequest, | ||
| PluginResponse, | ||
| SearchPluginsResponse, | ||
|
|
||
| // License Management | ||
| IssueLicenseRequest, | ||
| LicenseResponse, | ||
| ValidateLicenseResponse, | ||
|
|
||
| // Composer Service | ||
| CompileManifestRequest, | ||
| CompileManifestResponse, | ||
|
|
||
| // Health & Monitoring | ||
| HubHealthResponse, | ||
| HubMetricsResponse, | ||
| } from '@objectstack/spec/api'; |
There was a problem hiding this comment.
Unused imports CreateTenantRequest, PluginResponse, TenantResponse.
| import { | ||
| // Federation | ||
| Region, | ||
| FederationTopology, | ||
| TenantPlacementPolicy, | ||
|
|
||
| // Security | ||
| SecurityScanResult, | ||
| SecurityPolicy, | ||
| DependencyResolutionResult, | ||
| SBOM, | ||
| PluginProvenance, | ||
| PluginTrustScore, | ||
| } from '@objectstack/spec/hub'; |
There was a problem hiding this comment.
Unused import Region.
- Add missing TestSuite type export in testing.zod.ts - Prefix unused context parameters with underscore to satisfy TS6133 - All packages now compile successfully Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
The Hub protocol lacked REST API contracts, multi-region federation support, and plugin security infrastructure. This adds complete specifications for managing tenants, plugins, and workspaces at scale.
Changes
API Contracts (
api/hub.zod.ts- 960 lines)Complete HTTP API specifications with request/response schemas:
Federation Protocol (
hub/hub-federation.zod.ts- 500 lines)Multi-region deployment infrastructure:
Security Protocol (
hub/plugin-security.zod.ts- 650 lines)Supply chain security and dependency management:
Test Coverage
Documentation
hub-management-example.ts: 900+ lines of working examplesHUB_PROTOCOL_DEVELOPMENT_PLAN.md: Implementation roadmap (bilingual)HUB_PROTOCOL_SUMMARY.md: Executive summary (bilingual)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.