Skip to content

Add objectql, gateway, and adapter package types to manifest schema#328

Merged
hotlong merged 2 commits intocopilot/implement-objectql-plugin-registrationfrom
copilot/extend-type-enum-for-gateway-adapter
Jan 27, 2026
Merged

Add objectql, gateway, and adapter package types to manifest schema#328
hotlong merged 2 commits intocopilot/implement-objectql-plugin-registrationfrom
copilot/extend-type-enum-for-gateway-adapter

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 27, 2026

Extends the manifest type system to support microkernel architecture by distinguishing between runtime containers (adapters), API protocols (gateways), and core engine (objectql).

Changes

Schema Extension

Extended ManifestSchema.type enum with three new values:

type: z.enum([
  'app',        // Business application
  'plugin',     // General extension
  'driver',     // Southbound: DB/external service adapters
  'module',     // Shared code library
  'objectql',   // Core engine: Data layer implementation
  'gateway',    // Northbound: API protocol (GraphQL, REST, RPC)
  'adapter'     // Runtime container (Express, Hono, Fastify, Serverless)
])

Architectural Rationale

Adapter (singleton): HTTP server container at the outermost layer. One per runtime instance.

Gateway (multiplicity): Protocol translation layer. Multiple can coexist (e.g., GraphQL + REST simultaneously).

ObjectQL: Core query engine and business logic layer, separated from both transport and protocol concerns.

This enables proper lifecycle ordering: Adapter → ObjectQL Engine → Drivers → Gateways → Business Apps.

Test Coverage

Added manifest validation tests for:

  • ObjectQL engine package
  • GraphQL/REST gateway packages
  • Express/Hono adapter packages

Generated Artifacts

  • JSON Schema automatically updated with new enum values
  • API documentation regenerated
Original prompt

拉取请求: #326

这是一个非常好的架构思考。将 Express/Hono(HTTP 服务容器)和 GraphQL/REST(API 协议)从核心剥离,通过插件注册,完全符合 微内核 (Microkernel)六边形架构 (Hexagonal Architecture) 的设计理念。

针对您提到的两类需求(API 协议 和 HTTP 服务容器),建议在 driverplugin 之外,再增加两个明确的类型:gatewayadapter

建议修改方案

packages/spec/src/system/manifest.zod.ts 中,扩展 type 枚举:

type: z.enum([
  'app',        // 业务应用
  'plugin',     // 通用功能扩展
  'driver',     // 南向接口:数据库/外部服务适配 (Postgres, Mongo, S3)
  'module',     // 代码库/共享模块
  'objectql',   // 核心引擎:数据层实现
  'gateway',    // 北向接口:API 协议入口 (GraphQL, REST, RPC, OData)
  'adapter'     // 宿主适配:运行时容器 (Express, Hono, Fastify, Serverless)
]).describe('Type of package'),

为什么建议这样分类?

这不仅仅是命名的区别,更关乎 启动生命周期 (Lifecycle)基数约束 (Cardinality)

1. adapter (适配器) - 对应 Express, Hono

  • 角色: 容器/宿主 (Host)。它们负责启动 HTTP 服务器,监听端口,处理原始 Request/Response 对象。
  • 特性:
    • 排他性 (Singleton): 通常一个运行时实例只能有一个 HTTP Server Adapter(要么是 Express,要么是 Hono,不能同时接管同一个端口)。
    • 启动顺序: 最先初始化(或者最后启动监听),位于架构的最外层。
  • 示例: @objectstack/adapter-express, @objectstack/adapter-hono, @objectstack/adapter-lambda

2. gateway (网关) - 对应 GraphQL, REST, OData

  • 角色: 协议转换 (Protocol)。它们将外部请求转换为 ObjectStack 内部的 Call
  • 特性:
    • 共存性 (Multiplicity): 你可以在同一个实例中同时开启 GraphQL 和 REST API。
    • 依赖性: 依赖 objectql 引擎和 adapter 提供的路由能力。
  • 示例: @objectstack/gateway-graphql, @objectstack/gateway-rest, @objectstack/gateway-trpc

架构图示 (洋葱模型)

增加这两种类型后,您的系统 Manifest 结构将非常清晰地对应每一层:

External Request (Browser/Mobile)
      │
      ▼
[ Adapter ]  <-- type: 'adapter' (Express/Hono) 负责接收 HTTP 请求
      │
      ▼
[ Gateway ]  <-- type: 'gateway' (GraphQL/REST) 负责解析协议
      │
      ▼
[ Kernel  ]  <-- 核心调度
      │
      ▼
[ ObjectQL]  <-- type: 'objectql' (Query Engine) 负责业务逻辑
      │
      ▼
[ Driver  ]  <-- type: 'driver' (Postgres/Mongo) 负责持久化
      │
      ▼
 Database

总结

是的,非常有必要增加。这样做可以让 Kernel 的启动逻辑更加严谨:

  1. 先加载 Adapter 准备环境。
  2. 初始化 ObjectQL 引擎。
  3. 加载 Driver 连接数据库。
  4. 加载 Gateway 注册路由到 Adapter。
  5. 最后加载 App/Plugin 里的业务逻辑。

如果您同意这个分类,我可以为您创建一个 PR,将 manifest.zod.ts 中的类型定义更新为包含 objectql, gateway, 和 adapter


✨ 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
Copy link
Copy Markdown

vercel bot commented Jan 27, 2026

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

Project Deployment Review Updated (UTC)
spec Ready Ready Preview, Comment Jan 27, 2026 3:17pm

Request Review

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
@hotlong hotlong marked this pull request as ready for review January 27, 2026 15:16
Copilot AI review requested due to automatic review settings January 27, 2026 15:16
@github-actions github-actions bot added documentation Improvements or additions to documentation protocol:system tests size/m labels Jan 27, 2026
Copilot AI changed the title [WIP] Add gateway and adapter types to type enum Add objectql, gateway, and adapter package types to manifest schema Jan 27, 2026
Copilot AI requested a review from hotlong January 27, 2026 15:16
@hotlong hotlong merged commit 536f086 into copilot/implement-objectql-plugin-registration Jan 27, 2026
8 of 9 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation protocol:system size/m tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants