Repository navigation
Refactor: Migrate to @objectstack/runtime microkernel architecture - #154
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>
|
|
| @@ -0,0 +1,12 @@ | |||
| import { Controller, Get, Render } from '@nestjs/common'; | |||
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
| req['user'] = { | ||
| roles: ['guest'], | ||
| isSystem: false | ||
| } |
Check notice
Code scanning / CodeQL
Semicolon insertion Note
|
|
||
| // Get ObjectQL instance from service registry if available | ||
| if (ctx.hasService('objectql')) { | ||
| const objectql = ctx.getService('objectql'); |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
There was a problem hiding this comment.
Pull request overview
Migrates the repository toward a microkernel + plugin architecture by introducing a new runtime package and a server plugin, while deprecating the legacy monolithic kernel/server packages and updating workspace/docs accordingly.
Changes:
- Updated PNPM workspace/scripts to prefer
@objectstack/runtime+@objectos/plugin-serverand exclude deprecated packages. - Added
@objectos/plugin-server(NestJS-based) and runtime bootstrap entrypoints for plugin-based server startup. - Added migration and plugin development documentation; marked
@objectos/kerneland@objectos/serveras deprecated.
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 25 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Switches workspace scope to runtime + plugins; excludes deprecated kernel/server. |
| pnpm-lock.yaml | Lockfile updates reflecting workspace/package topology changes. |
| packages/server/package.json | Marks @objectos/server as deprecated. |
| packages/server/README.md | Adds deprecation notice and migration guidance for server consumers. |
| packages/runtime/src/index.ts | Minor export surface formatting update. |
| packages/plugins/server/tsconfig.json | Adds TS config for new server plugin package. |
| packages/plugins/server/src/plugin.ts | Implements server as a runtime plugin (init/start/destroy lifecycle). |
| packages/plugins/server/src/objectql/objectql.provider.ts | Provides ObjectQL instance to Nest module (currently via kernel bootstrap inside provider). |
| packages/plugins/server/src/objectql/objectql.module.ts | Registers the ObjectQL provider as a global Nest module. |
| packages/plugins/server/src/main.ts | Standalone NestJS bootstrap entrypoint (non-kernel startup). |
| packages/plugins/server/src/index.ts | Exports server plugin API and re-exports Nest components. |
| packages/plugins/server/src/bootstrap.ts | Runtime microkernel bootstrap entrypoint wiring Driver/ObjectQL/Server plugins. |
| packages/plugins/server/src/auth/auth.module.ts | Adds Nest auth module wrapper. |
| packages/plugins/server/src/auth/auth.middleware.ts | Adds request authentication middleware integrating Better-Auth session lookup. |
| packages/plugins/server/src/auth/auth.controller.ts | Adds /api/auth/* passthrough controller. |
| packages/plugins/server/src/auth/auth.client.ts | Initializes Better-Auth with multi-db support. |
| packages/plugins/server/src/app.service.ts | Adds basic Nest service. |
| packages/plugins/server/src/app.module.ts | Configures REST/metadata/RPC handlers and middleware routing. |
| packages/plugins/server/src/app.controller.ts | Adds /api/health endpoint. |
| packages/plugins/server/package.json | Defines @objectos/plugin-server package metadata and scripts/deps. |
| packages/plugins/server/README.md | Documents plugin usage, configuration, endpoints, and migration notes. |
| packages/kernel/package.json | Marks @objectos/kernel as deprecated. |
| packages/kernel/README.md | Adds deprecation notice and migration guidance for kernel consumers. |
| package.json | Updates root scripts to use @objectos/plugin-server and removes runtime patch. |
| docs/guide/plugin-development.md | Adds plugin development guide for the runtime microkernel. |
| docs/guide/migration-from-kernel.md | Adds kernel/server → runtime/plugin migration guide. |
| README.md | Updates package role table to emphasize plugin-server and deprecations. |
| MICROKERNEL_MIGRATION_SUMMARY.md | Adds overall migration summary and status/known issues. |
| ARCHITECTURE.md | Updates architecture docs to reflect runtime + plugins model. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| ### Need Help? | ||
|
|
||
| - See the [Server Plugin Documentation](../plugins/server/README.md) | ||
| - Check the [Migration Guide](../../docs/guide/migration-from-server.md) |
There was a problem hiding this comment.
This README references ../../docs/guide/migration-from-server.md, but that file doesn’t exist in docs/guide/ (the repo has migration-from-kernel.md). Update the link to an existing migration doc to avoid broken documentation.
| - Check the [Migration Guide](../../docs/guide/migration-from-server.md) | |
| - Check the [Migration Guide](../../docs/guide/migration-from-kernel.md) |
| // Create the ObjectKernel | ||
| const kernel = new ObjectKernel(); | ||
|
|
||
| // Register ObjectQL plugin - it will create its own ObjectQL instance | ||
| kernel.use(new ObjectQLPlugin()); |
There was a problem hiding this comment.
This provider bootstraps a new ObjectKernel inside Nest DI. When the server itself is a runtime plugin, this creates a second isolated kernel/ObjectQL instance and bypasses the host kernel’s service registry/lifecycle. Instead, pass the host objectql instance into Nest (e.g. via createServerPlugin({ objectql }) or a dynamic module) and avoid creating a nested kernel here.
| if (!config.datasource || Object.keys(config.datasource).length === 0) { | ||
| console.warn('No datasource found in config, using default SQLite connection.'); | ||
| const defaultDriver = new KnexDriver({ | ||
| client: 'sqlite3', | ||
| connection: { | ||
| filename: ':memory:' |
There was a problem hiding this comment.
Defaulting to an in-memory SQLite datasource when no config is found can lead to silent data loss (server appears to run but nothing persists). Consider failing fast in production, or only allowing :memory: when explicitly enabled for dev/testing.
| import { NestFactory } from '@nestjs/core'; | ||
|
|
||
| const serverPlugin = createServerPlugin({ | ||
| port: 3000, | ||
| configure: async (app) => { | ||
| // Add custom middleware | ||
| app.use((req, res, next) => { | ||
| console.log(`${req.method} ${req.url}`); | ||
| next(); | ||
| }); | ||
| } | ||
| }); |
There was a problem hiding this comment.
The README documents a configure option for createServerPlugin, but ServerPluginOptions doesn’t define/implement it. Either implement this hook (to allow customizing the Nest app) or remove it from the documentation.
| import { NestFactory } from '@nestjs/core'; | |
| const serverPlugin = createServerPlugin({ | |
| port: 3000, | |
| configure: async (app) => { | |
| // Add custom middleware | |
| app.use((req, res, next) => { | |
| console.log(`${req.method} ${req.url}`); | |
| next(); | |
| }); | |
| } | |
| }); | |
| import type { PluginContext } from '@objectstack/runtime'; | |
| const serverPlugin = createServerPlugin({ | |
| port: 3000, | |
| }); | |
| async function start(ctx: PluginContext) { | |
| // Get the NestJS app from service registry | |
| const app = ctx.getService('nestjs.app'); | |
| // Add custom middleware | |
| app.use((req, res, next) => { | |
| console.log(`${req.method} ${req.url}`); | |
| next(); | |
| }); | |
| } |
| import { ObjectKernel } from '@objectstack/runtime'; | ||
| import { ServerPlugin } from '@objectos/plugin-server'; | ||
| import { BetterAuthPlugin } from '@objectos/plugin-better-auth'; | ||
|
|
||
| const kernel = new ObjectKernel(); | ||
|
|
||
| kernel.use(BetterAuthPlugin); // Adds /api/auth/* routes | ||
| kernel.use(ServerPlugin); // HTTP server | ||
|
|
There was a problem hiding this comment.
The integration example uses kernel.use(BetterAuthPlugin), but @objectos/plugin-better-auth currently exports an @objectstack/spec plugin definition, not an @objectstack/runtime Plugin. As written, this example won’t compile/run with ObjectKernel.use(...) unless an adapter exists. Update the example (or provide an adapter layer).
| import { ObjectKernel } from '@objectstack/runtime'; | |
| import { ServerPlugin } from '@objectos/plugin-server'; | |
| import { BetterAuthPlugin } from '@objectos/plugin-better-auth'; | |
| const kernel = new ObjectKernel(); | |
| kernel.use(BetterAuthPlugin); // Adds /api/auth/* routes | |
| kernel.use(ServerPlugin); // HTTP server | |
| import { ObjectKernel, createRuntimePluginFromSpec } from '@objectstack/runtime'; | |
| import { ServerPlugin } from '@objectos/plugin-server'; | |
| import { BetterAuthPlugin } from '@objectos/plugin-better-auth'; | |
| const kernel = new ObjectKernel(); | |
| // Adapt the Better-Auth spec plugin into a runtime plugin before registering it | |
| const betterAuthRuntimePlugin = createRuntimePluginFromSpec(BetterAuthPlugin); | |
| kernel.use(betterAuthRuntimePlugin); // Adds /api/auth/* routes | |
| kernel.use(ServerPlugin); // HTTP server |
|
|
||
| import type { Plugin, PluginContext } from '@objectstack/runtime'; | ||
| import { NestFactory } from '@nestjs/core'; | ||
| import { AppModule } from './app.module'; |
There was a problem hiding this comment.
This file uses extensionless relative imports (e.g. ./app.module) while most other files in this package use .js specifiers for ESM output. If this package is meant to run as ESM (as implied by .js specifiers elsewhere), extensionless imports will not resolve in Node ESM. Standardize on one import style (prefer the .js specifiers consistently for Node ESM builds).
| import { AppModule } from './app.module'; | |
| import { AppModule } from './app.module.js'; |
| // Get a service registered by another plugin | ||
| const driver = ctx.getService('driver'); |
There was a problem hiding this comment.
This example uses ctx.getService('driver'), but the current runtime DriverPlugin doesn’t register a driver service in the registry. Update the docs to retrieve the correct service (objectql) or adjust the runtime/plugin contract to actually register a driver service.
| // Get a service registered by another plugin | |
| const driver = ctx.getService('driver'); | |
| // Get a service registered by another plugin (ObjectQL driver) | |
| const objectql = ctx.getService('objectql'); |
| @@ -0,0 +1,12 @@ | |||
| import { Controller, Get, Render } from '@nestjs/common'; | |||
There was a problem hiding this comment.
Unused import Render.
| import { Controller, Get, Render } from '@nestjs/common'; | |
| import { Controller, Get } from '@nestjs/common'; |
| // Get ObjectQL instance from service registry if available | ||
| if (ctx.hasService('objectql')) { | ||
| const objectql = ctx.getService('objectql'); | ||
| ctx.logger.debug('[Server Plugin] ObjectQL instance found in registry'); | ||
| // You could inject ObjectQL into the app here if needed |
There was a problem hiding this comment.
Unused variable objectql.
| // Get ObjectQL instance from service registry if available | |
| if (ctx.hasService('objectql')) { | |
| const objectql = ctx.getService('objectql'); | |
| ctx.logger.debug('[Server Plugin] ObjectQL instance found in registry'); | |
| // You could inject ObjectQL into the app here if needed | |
| // Log if an ObjectQL instance is available in the service registry | |
| if (ctx.hasService('objectql')) { | |
| ctx.logger.debug('[Server Plugin] ObjectQL instance found in registry'); | |
| // You could inject ObjectQL into the app here if needed, using ctx.getService('objectql') |
| req['user'] = { | ||
| roles: ['guest'], | ||
| isSystem: false | ||
| } |
There was a problem hiding this comment.
Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).
| } | |
| }; |
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
…p-configuration
|
|
- Add @types/pg and @types/better-sqlite3 dev dependencies - Fix type annotations in auth.controller.ts (Request, Response, error handling) - Add Express type augmentation for user property on Request - Update PluginContext interface to include getServices() and getKernel() methods - Implement getKernel() in PluginContextImpl and set kernel reference Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…e-configuration
|
Deployment failed with the following error: View Documentation: https://vercel.com/docs/accounts/team-members-and-roles |
|
|
Deprecates monolithic
@objectos/kerneland@objectos/serverin favor of microkernel plugin architecture using@objectstack/runtime.Changes
Deprecated Packages
@objectos/kernel→@objectstack/runtime@objectos/server→@objectos/plugin-serverBoth packages remain functional but marked deprecated in package.json with migration notices.
New Server Plugin
Created
@objectos/plugin-serverimplementing NestJS server as a runtime plugin:Architecture
Project Structure
@objectos/serverto@objectos/plugin-serverDocumentation
/docs/guide/migration-from-kernel.md- Migration guide with examples/docs/guide/plugin-development.md- Plugin development patternsMICROKERNEL_MIGRATION_SUMMARY.md- Architecture overviewKnown Issues
TypeScript compilation errors in server plugin (missing @types, PluginContext compatibility). Deferred to follow-up as runtime core is functional.
Migration Path
@objectos/kernel@objectstack/runtime@objectos/server@objectos/plugin-server@objectos/plugin-permissions(TODO)@objectos/plugin-workflow(TODO)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.