Skip to content
This repository was archived by the owner on Aug 10, 2026. It is now read-only.

Refactor: Migrate to @objectstack/runtime microkernel architecture - #154

Merged
xuyushun441-sys merged 12 commits into
mainfrom
copilot/refactor-kernel-and-server
Feb 1, 2026
Merged

xuyushun441-sys merged 12 commits into
mainfrom
copilot/refactor-kernel-and-server

Conversation

Copilot AI commented Feb 1, 2026 •

Copy link
Copy Markdown
Contributor

Deprecates monolithic @objectos/kernel and @objectos/server in favor of microkernel plugin architecture using @objectstack/runtime.

Changes

Deprecated Packages

  • @objectos/kernel → @objectstack/runtime
  • @objectos/server → @objectos/plugin-server

Both packages remain functional but marked deprecated in package.json with migration notices.

New Server Plugin

Created @objectos/plugin-server implementing NestJS server as a runtime plugin:

// Before: Monolithic server
const app = await NestFactory.create(AppModule);
await app.listen(3000);

// After: Plugin-based
const kernel = new ObjectKernel();
kernel.use(new DriverPlugin(driver, 'default'));
kernel.use(new ObjectQLPlugin());
kernel.use(createServerPlugin({ port: 3000 }));
await kernel.bootstrap();

Architecture

  • Runtime: Plugin lifecycle, service registry, event bus, dependency resolution
  • Plugins: Isolated features (server, auth, audit) with standardized hooks (init/start/destroy)
  • Benefits: Modular features, independent testing, third-party plugin ecosystem

Project Structure

  • Updated workspace config to include runtime, exclude deprecated packages
  • Migrated scripts from @objectos/server to @objectos/plugin-server
  • Removed obsolete runtime patch

Documentation

  • /docs/guide/migration-from-kernel.md - Migration guide with examples
  • /docs/guide/plugin-development.md - Plugin development patterns
  • MICROKERNEL_MIGRATION_SUMMARY.md - Architecture overview

Known Issues

TypeScript compilation errors in server plugin (missing @types, PluginContext compatibility). Deferred to follow-up as runtime core is functional.

Migration Path

Feature Old New
Kernel @objectos/kernel @objectstack/runtime
Server @objectos/server @objectos/plugin-server
Permissions Kernel built-in @objectos/plugin-permissions (TODO)
Workflow Kernel built-in @objectos/plugin-workflow (TODO)
Original prompt

计划作废kernel和server,使用 @objectstack/runtime微内核设计,项目主要开发插件,扩展os相关功能


💡 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.

@vercel

vercel Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
objectos Error Error Feb 1, 2026 8:22am

Request Review

Copilot AI and others added 3 commits February 1, 2026 02:59
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>
Copilot AI changed the title [WIP] Refactor kernel and server implementation using microkernel design Refactor: Migrate to @objectstack/runtime microkernel architecture Feb 1, 2026
Copilot AI requested a review from hotlong February 1, 2026 03:08
@hotlong
hotlong marked this pull request as ready for review February 1, 2026 05:58
Copilot AI review requested due to automatic review settings February 1, 2026 05:58
@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown

⚠️ This PR is very large. Consider breaking it down into smaller, more focused changes for easier review.

@github-actions github-actions Bot added documentation Improvements or additions to documentation server dependencies kernel and removed size/xl labels Feb 1, 2026
@@ -0,0 +1,12 @@
import { Controller, Get, Render } from '@nestjs/common';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import Render.
req['user'] = {
roles: ['guest'],
isSystem: false
}

Check notice

Code scanning / CodeQL

Semicolon insertion Note

Avoid automated semicolon insertion (93% of all statements in
the enclosing function
have an explicit semicolon).

// 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

Unused variable objectql.

Copilot AI 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

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-server and 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/kernel and @objectos/server as 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

Comment thread packages/server/README.md
### Need Help?

- See the [Server Plugin Documentation](../plugins/server/README.md)
- Check the [Migration Guide](../../docs/guide/migration-from-server.md)

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
- Check the [Migration Guide](../../docs/guide/migration-from-server.md)
- Check the [Migration Guide](../../docs/guide/migration-from-kernel.md)

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +47
// Create the ObjectKernel
const kernel = new ObjectKernel();

// Register ObjectQL plugin - it will create its own ObjectQL instance
kernel.use(new ObjectQLPlugin());

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +82
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:'

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines +245 to +256
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();
});
}
});

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
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();
});
}

Copilot uses AI. Check for mistakes.
Comment on lines +124 to +132
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

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Suggested change
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

Copilot uses AI. Check for mistakes.

import type { Plugin, PluginContext } from '@objectstack/runtime';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

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).

Suggested change
import { AppModule } from './app.module';
import { AppModule } from './app.module.js';

Copilot uses AI. Check for mistakes.
Comment on lines +86 to +87
// Get a service registered by another plugin
const driver = ctx.getService('driver');

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

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.

Suggested change
// 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');

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,12 @@
import { Controller, Get, Render } from '@nestjs/common';

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

Unused import Render.

Suggested change
import { Controller, Get, Render } from '@nestjs/common';
import { Controller, Get } from '@nestjs/common';

Copilot uses AI. Check for mistakes.
Comment on lines +71 to +75
// 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

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

Unused variable objectql.

Suggested change
// 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')

Copilot uses AI. Check for mistakes.
req['user'] = {
roles: ['guest'],
isSystem: false
}

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

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

Avoid automated semicolon insertion (93% of all statements in the enclosing function have an explicit semicolon).

Suggested change
}
};

Copilot uses AI. Check for mistakes.
Copilot AI and others added 4 commits February 1, 2026 07:45
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown

⚠️ This PR is very large. Consider breaking it down into smaller, more focused changes for easier review.

Copilot AI and others added 4 commits February 1, 2026 08:24
- 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>
@vercel

vercel Bot commented Feb 1, 2026

Copy link
Copy Markdown

Deployment failed with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: objectos.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

@github-actions github-actions Bot added size/xl and removed size/xl labels Feb 1, 2026
@github-actions

github-actions Bot commented Feb 1, 2026

Copy link
Copy Markdown

⚠️ This PR is very large. Consider breaking it down into smaller, more focused changes for easier review.

@xuyushun441-sys
xuyushun441-sys merged commit 9aa67b0 into main Feb 1, 2026
7 of 8 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants