Skip to content

Document dispatcher protocol in PROTOCOL_MAP - #549

Merged
hotlong merged 2 commits into
mainfrom
copilot/update-api-protocol-structure
Feb 8, 2026
Merged

Document dispatcher protocol in PROTOCOL_MAP#549
hotlong merged 2 commits into
mainfrom
copilot/update-api-protocol-structure

Conversation

CopilotAI commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Phase 1 API Protocol infrastructure was already complete. All requirements (CoreServiceName extensions, ApiRoutesSchema, dispatcher.zod.ts, ManifestSchema.contributes.routes, tests) existed. Only documentation was missing.

Changes

  • Added dispatcher.zod.ts to PROTOCOL_MAP.md as primary protocol (⭐)
  • Promoted discovery.zod.ts to primary protocol status
  • Clarified discovery includes API routes registry

Context

The HttpDispatcher protocol defines route-to-service mapping for 14 API namespaces:

// packages/spec/src/api/dispatcher.zod.tsexportconstDEFAULT_DISPATCHER_ROUTES=[{prefix: '/api/v1/discovery',service: 'metadata',authRequired: false},{prefix: '/api/v1/meta',service: 'metadata'},{prefix: '/api/v1/data',service: 'data'},{prefix: '/api/v1/ai',service: 'ai'},{prefix: '/api/v1/i18n',service: 'i18n'},{prefix: '/api/v1/ui',service: 'ui'},{prefix: '/api/v1/workflow',service: 'workflow'},// ... 7 more routes];

Plugins declare routes via ManifestSchema.contributes.routes, allowing dynamic API extension without kernel changes.

Phase 2 Scope

Phase 2 (REST API plugin implementation) requires code outside spec repository - not included in this PR.

Original prompt

完成 API Protocol 改造

Phase 1: 内核基础改造(1-2 周)

  • 1.1 扩展 CoreServiceName,增加 aii18nuiworkflow 四个服务标识
  • 1.2 扩展 ApiRoutesSchema,增加新的路由端点声明
  • 1.3 创建 src/api/dispatcher.zod.ts,定义 HttpDispatcher 路由配置协议
  • 1.4 扩展 ManifestSchema contributes.routes,允许插件声明 API 路由贡献
  • 1.5 补充所有相关 .test.ts 单元测试
  • 1.6 更新 PROTOCOL_MAP.md 文档

Phase 2: 核心 REST API 插件(2-3 周)

  • 2.1 实现 plugin-rest-api:注册 Discovery、Metadata、Data CRUD、Batch、Permission 路由
  • 2.2 Request 校验中间件:使用 Zod Schema 自动验证请求体
  • 2.3 Response 封装:统一使用 BaseResponseSchema 信封格式
  • 2.4 错误处理:统一使用 ApiErrorSchema 格式
  • 2.5 OpenAPI 文档自动生成(基于 documentation.zod.ts

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel

vercelBot commented Feb 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

ProjectDeploymentActionsUpdated (UTC)
objectstack-studioErrorErrorFeb 8, 2026 9:37am
specReadyReadyPreview, CommentFeb 8, 2026 9:37am

Request Review

…very
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
CopilotAI changed the title [WIP] Update API protocol for service integration and routingDocument dispatcher protocol in PROTOCOL_MAPFeb 8, 2026
CopilotAI requested a review from hotlongFebruary 8, 2026 09:39
@hotlong
hotlong marked this pull request as ready for review February 8, 2026 10:18
CopilotAI review requested due to automatic review settings February 8, 2026 10:18
@hotlong
hotlong merged commit 6028495 into mainFeb 8, 2026
6 of 7 checks passed

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the ObjectStack spec documentation map and regenerates/extends JSON Schema artifacts to reflect the HttpDispatcher + Discovery routing model and newly recognized core services.

Changes:

  • Documented dispatcher.zod.ts as a primary (⭐) API protocol and promoted discovery.zod.ts to ⭐ in PROTOCOL_MAP.md.
  • Updated generated JSON schemas to include new CoreServiceName values (ai, i18n, ui, workflow) and expanded Discovery/Routes outputs to use /api/v1/* examples and include additional namespaces.
  • Added/updated generated JSON schemas for dispatcher configuration (DispatcherRoute, DispatcherConfig) and manifest contributes.routes structures across multiple response schemas.

Reviewed changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
packages/spec/PROTOCOL_MAP.mdAdds dispatcher + promotes discovery to ⭐ in the protocol map.
packages/spec/json-schema/system/ServiceStatus.jsonExtends service enum with ai/i18n/ui/workflow.
packages/spec/json-schema/system/ServiceConfig.jsonExtends service enum with ai/i18n/ui/workflow.
packages/spec/json-schema/system/KernelServiceMap.jsonExtends service enum with ai/i18n/ui/workflow.
packages/spec/json-schema/system/CoreServiceName.jsonExtends core service enum with ai/i18n/ui/workflow.
packages/spec/json-schema/kernel/Manifest.jsonAdds generated schema for contributes.routes.
packages/spec/json-schema/kernel/ListPackagesResponse.jsonPropagates contributes.routes into response schema.
packages/spec/json-schema/kernel/InstalledPackage.jsonPropagates contributes.routes into response schema.
packages/spec/json-schema/kernel/InstallPackageResponse.jsonPropagates contributes.routes into response schema.
packages/spec/json-schema/kernel/InstallPackageRequest.jsonPropagates contributes.routes into request schema.
packages/spec/json-schema/kernel/GetPackageResponse.jsonPropagates contributes.routes into response schema.
packages/spec/json-schema/kernel/EnablePackageResponse.jsonPropagates contributes.routes into response schema.
packages/spec/json-schema/kernel/DisablePackageResponse.jsonPropagates contributes.routes into response schema.
packages/spec/json-schema/hub/ComposerResponse.jsonPropagates contributes.routes into response schema.
packages/spec/json-schema/api/ListPackagesResponse.jsonPropagates contributes.routes into API response schema.
packages/spec/json-schema/api/InstallPackageResponse.jsonPropagates contributes.routes into API response schema.
packages/spec/json-schema/api/InstallPackageRequest.jsonPropagates contributes.routes into API request schema.
packages/spec/json-schema/api/GetPackageResponse.jsonPropagates contributes.routes into API response schema.
packages/spec/json-schema/api/EnablePackageResponse.jsonPropagates contributes.routes into API response schema.
packages/spec/json-schema/api/DisablePackageResponse.jsonPropagates contributes.routes into API response schema.
packages/spec/json-schema/api/CompileManifestResponse.jsonPropagates contributes.routes into API response schema.
packages/spec/json-schema/api/GetDiscoveryResponse.jsonExpands discovery endpoints/features to include more namespaces and /api/v1/* examples.
packages/spec/json-schema/api/Discovery.jsonExpands discovery schema (routes + features) to include more namespaces and /api/v1/* examples.
packages/spec/json-schema/api/ApiRoutes.jsonAdds additional route namespaces and updates examples to /api/v1/*.
packages/spec/json-schema/api/ApiCapabilities.jsonAdds capabilities flags for ai/workflow/notifications/i18n.
packages/spec/json-schema/api/DispatcherRoute.jsonAdds generated JSON schema for dispatcher route entries.
packages/spec/json-schema/api/DispatcherConfig.jsonAdds generated JSON schema for dispatcher config.

| :--- | :--- | :--- |
| [`protocol.zod.ts`](src/api/protocol.zod.ts) | ⭐ | **Stack Protocol**. valid requests and responses for the platform. |
| [`dispatcher.zod.ts`](src/api/dispatcher.zod.ts) | ⭐ | **HttpDispatcher**. Route-to-service mapping for API routing. |
| [`discovery.zod.ts`](src/api/discovery.zod.ts) | ⭐ | **Service Discovery**. Service registration and API routes discovery. |

CopilotAIFeb 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PROTOCOL_MAP marks discovery.zod.ts as “Service registration and API routes discovery”, but src/api/discovery.zod.ts only defines a discovery response (routes + feature flags + locale). Consider rewording this row to avoid implying an unmodeled “service registration” protocol (or link that concept to kernel/service-registry.zod.ts if that’s what you mean).

Suggested change
|[`discovery.zod.ts`](src/api/discovery.zod.ts)||**Service Discovery**. Service registration and API routes discovery. |
|[`discovery.zod.ts`](src/api/discovery.zod.ts)||**API Discovery Response**. Describes available API routes, feature flags, and locale metadata. |

Copilot uses AI. Check for mistakes.
Comment on lines 157 to +159
| [`protocol.zod.ts`](src/api/protocol.zod.ts) | ⭐ | **Stack Protocol**. valid requests and responses for the platform. |
| [`dispatcher.zod.ts`](src/api/dispatcher.zod.ts) | ⭐ | **HttpDispatcher**. Route-to-service mapping for API routing. |
| [`discovery.zod.ts`](src/api/discovery.zod.ts) | ⭐ | **Service Discovery**. Service registration and API routes discovery. |

CopilotAIFeb 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description says Phase 1 infrastructure (schemas + tests) already existed and that only PROTOCOL_MAP needed updates, but this PR also modifies/adds many packages/spec/json-schema/** artifacts (e.g., new DispatcherConfig/DispatcherRoute schemas and CoreServiceName enum expansions). Please either update the PR description to reflect the additional non-doc changes, or drop the generated schema changes if they’re unintended.

Copilot uses AI. Check for mistakes.
"description": "API path prefix"
},
"service": {
"type": "string",

CopilotAIFeb 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In contributes.routes, service is an unconstrained string. Since HttpDispatcher routes use CoreServiceName (enum), allowing arbitrary values here makes manifests validate even when the dispatcher/service-registry can’t resolve them. Recommend constraining service to the CoreServiceName enum in the source Zod schema and regenerating JSON schema outputs.

Suggested change
"type": "string",
"$ref": "#/definitions/CoreServiceName",

Copilot uses AI. Check for mistakes.
"description": "API path prefix"
},
"service": {
"type": "string",

CopilotAIFeb 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contributes.routes[].service is typed as a free-form string here as well. If this field is meant to integrate with HttpDispatcher routing, it should be constrained to the same CoreServiceName enum used by DispatcherRoute.service, otherwise invalid service names will pass manifest compilation but fail at routing time.

Suggested change
"type": "string",
"$ref": "#/definitions/CoreServiceName",

Copilot uses AI. Check for mistakes.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@hotlong