This document describes the alignment of ObjectOS with the @objectstack/spec protocol.
Current Version: v0.4.1 (Updated: 2026-01-27)
Previous Version: v0.3.3
@objectstack/spec is the "Constitution" of the ObjectStack ecosystem. It defines:
- Zod Schemas: Runtime validation for the Kernel and CLI
- TypeScript Interfaces: Type-safe definitions for plugins and applications
- JSON Schemas: Auto-generated schemas for VS Code IntelliSense
Guiding Principle: "Strict Types, No Logic"
The specification is organized into five namespaces:
Business Kernel & Data Logic
Object,Field,ValidationQuery(AST),Driver(Interface),DatasourcePermission,Sharing,Flow
Plugin System, Runtime Infrastructure & Security
Manifest- Plugin configuration with contribution pointsPlugin- Lifecycle hooks (onInstall, onEnable, onDisable, onUninstall)Context- Runtime context available to plugins (KernelContext, PluginContextData)Logger- Structured loggingAudit- Audit logging and event trackingEvents- Event bus and handlersJob- Scheduled jobs and background tasks
Note: In v0.4.1, the Kernel Protocol was merged into the System Protocol for better organization.
Presentation & Interaction
App,Page,View(Grid/Kanban)Dashboard(Widgets),ReportAction(Triggers)
Connectivity & Contracts
Contract(DTOs),Endpoint(Gateway)Discovery(Metadata),Realtime(Socket)
Authentication & Authorization
User,Session,RolePermission,Token
Added:
@objectstack/spec@0.3.3- Core protocol specification
Updated:
- TypeScript module resolution to
node16for better subpath export support
Before:
// Old: Direct ObjectQL types
export * from '@objectql/types';After:
// New: Spec-based types with legacy compatibility
export type {
PluginDefinition,
PluginContextData,
ObjectStackManifest,
} from '@objectstack/spec/system';
export type {
ServiceObject,
Field,
QueryAST,
} from '@objectstack/spec/data';
export type {
AuditEvent,
Job,
} from '@objectstack/spec/system';
// Legacy compatibility maintained
export * from '@objectql/types';The spec defines a clear separation between:
Manifest (Static Configuration):
const MyPluginManifest: ObjectStackManifest = {
id: 'com.company.plugin',
version: '1.0.0',
type: 'plugin',
name: 'My Plugin',
permissions: ['system.user.read'],
objects: ['./objects/*.yml'],
definitions: { /* inline object schemas */ },
};Lifecycle Hooks (Runtime Behavior):
const MyPlugin: PluginDefinition = {
async onInstall(context) { /* setup */ },
async onEnable(context) { /* activate */ },
async onDisable(context) { /* cleanup */ },
async onUninstall(context) { /* final cleanup */ },
};The spec defines a comprehensive PluginContextData interface providing:
context.ql: ObjectQL data accesscontext.os: ObjectOS system APIcontext.logger: Structured loggingcontext.storage: Plugin-scoped key-value storagecontext.i18n: Internationalizationcontext.metadata: Access to object schemascontext.events: Event buscontext.app.router: HTTP route registrationcontext.app.scheduler: Job schedulingcontext.drivers: Driver registry
Updated Files:
README.md- Added protocol compliance sectionARCHITECTURE.md- Added comprehensive spec explanationpackages/kernel/README.md- Added spec-compliant plugin documentation
Added Files:
packages/kernel/src/plugins/example-spec-plugin.ts- Complete example demonstrating spec compliance
Old Style (ObjectQL Plugin):
export const MyPlugin: ObjectQLPlugin = {
name: 'my-plugin',
async setup(app: IObjectQL) {
// Setup logic
}
};New Style (ObjectStack Spec Plugin):
import type { PluginDefinition, PluginContextData } from '@objectstack/spec/system';
export const MyPlugin: PluginDefinition = {
async onEnable(context: PluginContextData) {
// Access all capabilities through context
context.logger.info('Plugin enabled');
// Register routes
context.app.router.post('/api/my-endpoint', handler);
// Access data
const records = await context.ql.object('accounts').find({});
}
};The API remains mostly unchanged. The main difference is better type safety:
import { ObjectOS } from '@objectos/kernel';
import type { ObjectStackManifest } from '@objectstack/spec/system';
const os = new ObjectOS({
plugins: [MyPlugin],
// ... other config
});
await os.init();- All types are now centrally defined in
@objectstack/spec - Runtime validation with Zod schemas
- Compile-time type checking with TypeScript
- Consistent protocol across ObjectQL, ObjectOS, and ObjectUI
- Plugins work across different implementations
- JSON Schema for tooling support
- Types serve as documentation
- Examples demonstrate best practices
- VS Code IntelliSense for YAML files
- Protocol evolution through versioning
- Backward compatibility through legacy exports
- Clear migration paths
All existing tests pass without modification. The refactoring is backward-compatible:
pnpm --filter @objectos/kernel test
# ✓ 27 tests passedAll packages build successfully:
pnpm --filter @objectos/kernel build # ✓
pnpm --filter @objectos/server build # ✓See packages/kernel/src/plugins/example-spec-plugin.ts for a complete, production-ready example demonstrating:
- Proper manifest structure
- All lifecycle hooks
- Route registration
- Job scheduling
- Data access
- Error handling
- Logging best practices
- Kernel Enhancement: Implement manifest loader to separate manifest from lifecycle hooks
- Plugin Registry: Build a plugin discovery and management system
- Runtime Validation: Add Zod schema validation for plugin manifests
- Context Implementation: Fully implement all PluginContextData capabilities
- Migration Tooling: Create tools to help migrate existing plugins
This refactoring establishes ObjectOS as a spec-compliant member of the ObjectStack ecosystem, ensuring consistency, type safety, and interoperability while maintaining backward compatibility with existing code.