@objectstack/core 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/{ENHANCED_FEATURES.md → ADVANCED_FEATURES.md} +13 -13
  2. package/CHANGELOG.md +7 -0
  3. package/PHASE2_IMPLEMENTATION.md +388 -0
  4. package/README.md +24 -11
  5. package/REFACTORING_SUMMARY.md +40 -0
  6. package/dist/api-registry-plugin.test.js +20 -20
  7. package/dist/dependency-resolver.d.ts +62 -0
  8. package/dist/dependency-resolver.d.ts.map +1 -0
  9. package/dist/dependency-resolver.js +317 -0
  10. package/dist/dependency-resolver.test.d.ts +2 -0
  11. package/dist/dependency-resolver.test.d.ts.map +1 -0
  12. package/dist/dependency-resolver.test.js +241 -0
  13. package/dist/health-monitor.d.ts +65 -0
  14. package/dist/health-monitor.d.ts.map +1 -0
  15. package/dist/health-monitor.js +269 -0
  16. package/dist/health-monitor.test.d.ts +2 -0
  17. package/dist/health-monitor.test.d.ts.map +1 -0
  18. package/dist/health-monitor.test.js +68 -0
  19. package/dist/hot-reload.d.ts +79 -0
  20. package/dist/hot-reload.d.ts.map +1 -0
  21. package/dist/hot-reload.js +313 -0
  22. package/dist/index.d.ts +4 -1
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +5 -1
  25. package/dist/kernel-base.d.ts +2 -2
  26. package/dist/kernel-base.js +2 -2
  27. package/dist/kernel.d.ts +79 -31
  28. package/dist/kernel.d.ts.map +1 -1
  29. package/dist/kernel.js +383 -73
  30. package/dist/kernel.test.js +373 -122
  31. package/dist/lite-kernel.d.ts +55 -0
  32. package/dist/lite-kernel.d.ts.map +1 -0
  33. package/dist/lite-kernel.js +112 -0
  34. package/dist/lite-kernel.test.d.ts +2 -0
  35. package/dist/lite-kernel.test.d.ts.map +1 -0
  36. package/dist/lite-kernel.test.js +161 -0
  37. package/dist/logger.d.ts +2 -2
  38. package/dist/logger.d.ts.map +1 -1
  39. package/dist/logger.js +26 -7
  40. package/dist/plugin-loader.d.ts +11 -0
  41. package/dist/plugin-loader.d.ts.map +1 -1
  42. package/dist/plugin-loader.js +34 -10
  43. package/dist/plugin-loader.test.js +9 -0
  44. package/dist/security/index.d.ts +3 -0
  45. package/dist/security/index.d.ts.map +1 -1
  46. package/dist/security/index.js +4 -0
  47. package/dist/security/permission-manager.d.ts +96 -0
  48. package/dist/security/permission-manager.d.ts.map +1 -0
  49. package/dist/security/permission-manager.js +235 -0
  50. package/dist/security/permission-manager.test.d.ts +2 -0
  51. package/dist/security/permission-manager.test.d.ts.map +1 -0
  52. package/dist/security/permission-manager.test.js +220 -0
  53. package/dist/security/sandbox-runtime.d.ts +115 -0
  54. package/dist/security/sandbox-runtime.d.ts.map +1 -0
  55. package/dist/security/sandbox-runtime.js +310 -0
  56. package/dist/security/security-scanner.d.ts +92 -0
  57. package/dist/security/security-scanner.d.ts.map +1 -0
  58. package/dist/security/security-scanner.js +273 -0
  59. package/examples/{enhanced-kernel-example.ts → kernel-features-example.ts} +6 -6
  60. package/examples/phase2-integration.ts +355 -0
  61. package/package.json +2 -2
  62. package/src/api-registry-plugin.test.ts +20 -20
  63. package/src/dependency-resolver.test.ts +287 -0
  64. package/src/dependency-resolver.ts +388 -0
  65. package/src/health-monitor.test.ts +81 -0
  66. package/src/health-monitor.ts +316 -0
  67. package/src/hot-reload.ts +388 -0
  68. package/src/index.ts +6 -1
  69. package/src/kernel-base.ts +2 -2
  70. package/src/kernel.test.ts +469 -134
  71. package/src/kernel.ts +464 -78
  72. package/src/lite-kernel.test.ts +200 -0
  73. package/src/lite-kernel.ts +135 -0
  74. package/src/logger.ts +28 -7
  75. package/src/plugin-loader.test.ts +10 -1
  76. package/src/plugin-loader.ts +42 -13
  77. package/src/security/index.ts +19 -0
  78. package/src/security/permission-manager.test.ts +256 -0
  79. package/src/security/permission-manager.ts +336 -0
  80. package/src/security/sandbox-runtime.ts +432 -0
  81. package/src/security/security-scanner.ts +365 -0
  82. package/dist/enhanced-kernel.d.ts +0 -103
  83. package/dist/enhanced-kernel.d.ts.map +0 -1
  84. package/dist/enhanced-kernel.js +0 -403
  85. package/dist/enhanced-kernel.test.d.ts +0 -2
  86. package/dist/enhanced-kernel.test.d.ts.map +0 -1
  87. package/dist/enhanced-kernel.test.js +0 -412
  88. package/src/enhanced-kernel.test.ts +0 -535
  89. package/src/enhanced-kernel.ts +0 -496
@@ -1,10 +1,10 @@
1
- # Enhanced ObjectKernel - Advanced Plugin Features
1
+ # ObjectKernel - Advanced Plugin Features
2
2
 
3
- This document describes the enhanced features added to ObjectKernel for production-grade plugin management.
3
+ This document describes the advanced features of ObjectKernel for production-grade plugin management.
4
4
 
5
5
  ## Overview
6
6
 
7
- The `EnhancedObjectKernel` extends the basic `ObjectKernel` with enterprise-grade features for plugin lifecycle management, dependency injection, and operational resilience.
7
+ The `ObjectKernel` (formerly `EnhancedObjectKernel`) provides enterprise-grade features for plugin lifecycle management, dependency injection, and operational resilience.
8
8
 
9
9
  ## Features
10
10
 
@@ -13,9 +13,9 @@ The `EnhancedObjectKernel` extends the basic `ObjectKernel` with enterprise-grad
13
13
  Async plugin loading with comprehensive validation:
14
14
 
15
15
  ```typescript
16
- import { EnhancedObjectKernel, PluginMetadata } from '@objectstack/core';
16
+ import { ObjectKernel, PluginMetadata } from '@objectstack/core';
17
17
 
18
- const kernel = new EnhancedObjectKernel({
18
+ const kernel = new ObjectKernel({
19
19
  logger: { level: 'info' },
20
20
  defaultStartupTimeout: 30000, // 30 seconds
21
21
  gracefulShutdown: true,
@@ -242,7 +242,7 @@ for (const [pluginName, startTime] of metrics) {
242
242
  Properly cleanup resources on shutdown:
243
243
 
244
244
  ```typescript
245
- const kernel = new EnhancedObjectKernel({
245
+ const kernel = new ObjectKernel({
246
246
  gracefulShutdown: true,
247
247
  shutdownTimeout: 60000 // 60 second timeout
248
248
  });
@@ -309,25 +309,25 @@ const plugin: PluginMetadata = {
309
309
  };
310
310
  ```
311
311
 
312
- ## Migration from ObjectKernel
312
+ ## Migration from LiteKernel
313
313
 
314
- To migrate from `ObjectKernel` to `EnhancedObjectKernel`:
314
+ To migrate from `LiteKernel` to `ObjectKernel`:
315
315
 
316
316
  ```typescript
317
317
  // Before
318
- import { ObjectKernel } from '@objectstack/core';
319
- const kernel = new ObjectKernel();
318
+ import { LiteKernel } from '@objectstack/core';
319
+ const kernel = new LiteKernel();
320
320
 
321
321
  // After
322
- import { EnhancedObjectKernel } from '@objectstack/core';
323
- const kernel = new EnhancedObjectKernel({
322
+ import { ObjectKernel } from '@objectstack/core';
323
+ const kernel = new ObjectKernel({
324
324
  logger: { level: 'info' },
325
325
  gracefulShutdown: true,
326
326
  rollbackOnFailure: true
327
327
  });
328
328
  ```
329
329
 
330
- Both kernels are compatible - `EnhancedObjectKernel` is a superset of `ObjectKernel`.
330
+ Both kernels adhere to the same `Plugin` interface, but `ObjectKernel` supports advanced features like Rollback, Sandbox, and Hot Reload.
331
331
 
332
332
  ## Best Practices
333
333
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @objectstack/core
2
2
 
3
+ ## 0.9.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @objectstack/spec@0.9.2
9
+
3
10
  ## 0.9.1
4
11
 
5
12
  ### Patch Changes
@@ -0,0 +1,388 @@
1
+ # ObjectStack Phase 2 Implementation
2
+
3
+ This document describes the Phase 2 implementation of the ObjectStack Microkernel and Plugin Architecture Improvement Plan.
4
+
5
+ ## Overview
6
+
7
+ Phase 2 implements the core runtime features for advanced plugin lifecycle management, dependency resolution, and security sandboxing. These components build upon the protocol definitions from Phase 1 and provide production-ready implementations.
8
+
9
+ ## Components
10
+
11
+ ### 1. Health Monitor (`health-monitor.ts`)
12
+
13
+ The Health Monitor provides real-time health checking and auto-recovery for plugins.
14
+
15
+ **Features:**
16
+ - Configurable health check intervals
17
+ - Automatic failure detection with thresholds
18
+ - Auto-restart with backoff strategies (fixed, linear, exponential)
19
+ - Health status tracking (healthy, degraded, unhealthy, failed, recovering, unknown)
20
+ - Metrics collection (uptime, memory, CPU, connections, error rate)
21
+
22
+ **Usage:**
23
+
24
+ ```typescript
25
+ import { PluginHealthMonitor } from '@objectstack/core';
26
+
27
+ const monitor = new PluginHealthMonitor(logger);
28
+
29
+ // Register a plugin for monitoring
30
+ monitor.registerPlugin('my-plugin', {
31
+ interval: 30000, // Check every 30 seconds
32
+ timeout: 5000, // 5 second timeout
33
+ failureThreshold: 3, // Mark unhealthy after 3 failures
34
+ successThreshold: 1, // Mark healthy after 1 success
35
+ autoRestart: true, // Auto-restart on failure
36
+ maxRestartAttempts: 3, // Max 3 restart attempts
37
+ restartBackoff: 'exponential',
38
+ });
39
+
40
+ // Start monitoring
41
+ monitor.startMonitoring('my-plugin', pluginInstance);
42
+
43
+ // Get health status
44
+ const status = monitor.getHealthStatus('my-plugin');
45
+ const report = monitor.getHealthReport('my-plugin');
46
+ ```
47
+
48
+ ### 2. Hot Reload Manager (`hot-reload.ts`)
49
+
50
+ The Hot Reload Manager enables zero-downtime plugin updates with state preservation.
51
+
52
+ **Features:**
53
+ - State preservation strategies (memory, disk, distributed, none)
54
+ - File watching integration points
55
+ - Debounced reload scheduling
56
+ - Graceful shutdown with configurable timeout
57
+ - Before/after reload hooks
58
+ - State checksum verification
59
+
60
+ **Usage:**
61
+
62
+ ```typescript
63
+ import { HotReloadManager } from '@objectstack/core';
64
+
65
+ const hotReload = new HotReloadManager(logger);
66
+
67
+ // Register plugin for hot reload
68
+ hotReload.registerPlugin('my-plugin', {
69
+ enabled: true,
70
+ watchPatterns: ['src/**/*.ts'],
71
+ debounceDelay: 1000,
72
+ preserveState: true,
73
+ stateStrategy: 'memory',
74
+ shutdownTimeout: 30000,
75
+ beforeReload: ['plugin:beforeReload'],
76
+ afterReload: ['plugin:afterReload'],
77
+ });
78
+
79
+ // Trigger reload
80
+ await hotReload.reloadPlugin(
81
+ 'my-plugin',
82
+ pluginInstance,
83
+ '1.2.0',
84
+ () => ({ /* current state */ }),
85
+ (state) => { /* restore state */ }
86
+ );
87
+ ```
88
+
89
+ ### 3. Dependency Resolver (`dependency-resolver.ts`)
90
+
91
+ The Dependency Resolver provides semantic versioning and dependency management.
92
+
93
+ **Features:**
94
+ - Full SemVer parsing and comparison
95
+ - Version constraint matching (^, ~, >=, <=, <, >, -, *, latest)
96
+ - Topological sorting (Kahn's algorithm)
97
+ - Circular dependency detection
98
+ - Version conflict detection
99
+ - Compatibility level assessment
100
+ - Best version selection
101
+
102
+ **Usage:**
103
+
104
+ ```typescript
105
+ import {
106
+ SemanticVersionManager,
107
+ DependencyResolver
108
+ } from '@objectstack/core';
109
+
110
+ // Parse and compare versions
111
+ const v1 = SemanticVersionManager.parse('1.2.3');
112
+ const v2 = SemanticVersionManager.parse('1.3.0');
113
+ const cmp = SemanticVersionManager.compare(v1, v2); // -1
114
+
115
+ // Check if version satisfies constraint
116
+ const satisfies = SemanticVersionManager.satisfies(v1, '^1.0.0'); // true
117
+
118
+ // Get compatibility level
119
+ const compat = SemanticVersionManager.getCompatibilityLevel(v1, v2);
120
+ // 'backward-compatible'
121
+
122
+ // Resolve dependencies
123
+ const resolver = new DependencyResolver(logger);
124
+
125
+ const plugins = new Map([
126
+ ['core', { dependencies: [] }],
127
+ ['plugin-a', { dependencies: ['core'] }],
128
+ ['plugin-b', { dependencies: ['core', 'plugin-a'] }],
129
+ ]);
130
+
131
+ const order = resolver.resolve(plugins);
132
+ // ['core', 'plugin-a', 'plugin-b']
133
+
134
+ // Detect conflicts
135
+ const conflicts = resolver.detectConflicts(pluginsWithVersions);
136
+
137
+ // Find best version
138
+ const best = resolver.findBestVersion(
139
+ ['1.0.0', '1.1.0', '1.2.0', '2.0.0'],
140
+ ['^1.0.0', '>=1.1.0']
141
+ );
142
+ // '1.2.0'
143
+ ```
144
+
145
+ ### 4. Permission Manager (`security/permission-manager.ts`)
146
+
147
+ The Permission Manager enforces fine-grained access control for plugins.
148
+
149
+ **Features:**
150
+ - Resource-level permissions (data, UI, system, storage, network, process)
151
+ - Action-based access control (create, read, update, delete, execute, etc.)
152
+ - Permission scopes (global, tenant, user, resource, plugin)
153
+ - Grant/revoke mechanisms
154
+ - Permission expiration
155
+ - Required vs optional permissions
156
+ - Field-level access control
157
+
158
+ **Usage:**
159
+
160
+ ```typescript
161
+ import { PluginPermissionManager } from '@objectstack/core/security';
162
+
163
+ const permManager = new PluginPermissionManager(logger);
164
+
165
+ // Register permissions
166
+ permManager.registerPermissions('my-plugin', {
167
+ permissions: [
168
+ {
169
+ id: 'read-customer-data',
170
+ resource: 'data.object',
171
+ actions: ['read'],
172
+ scope: 'plugin',
173
+ description: 'Read customer data',
174
+ required: true,
175
+ filter: {
176
+ resourceIds: ['customer'],
177
+ fields: ['name', 'email'],
178
+ },
179
+ },
180
+ ],
181
+ defaultGrant: 'prompt',
182
+ });
183
+
184
+ // Grant permission
185
+ permManager.grantPermission('my-plugin', 'read-customer-data', 'admin');
186
+
187
+ // Check access
188
+ const result = permManager.checkAccess(
189
+ 'my-plugin',
190
+ 'data.object',
191
+ 'read',
192
+ 'customer'
193
+ );
194
+
195
+ if (result.allowed) {
196
+ // Proceed with operation
197
+ }
198
+
199
+ // Check all required permissions
200
+ const hasAll = permManager.hasAllRequiredPermissions('my-plugin');
201
+ ```
202
+
203
+ ### 5. Sandbox Runtime (`security/sandbox-runtime.ts`)
204
+
205
+ The Sandbox Runtime provides isolated execution environments with resource limits.
206
+
207
+ **Features:**
208
+ - Multiple isolation levels (none, minimal, standard, strict, paranoid)
209
+ - File system access control (allowed/denied paths)
210
+ - Network access control (allowed/blocked hosts)
211
+ - Process spawning control
212
+ - Environment variable access control
213
+ - Resource limit enforcement (memory, CPU, connections)
214
+ - Resource usage monitoring
215
+
216
+ **Usage:**
217
+
218
+ ```typescript
219
+ import { PluginSandboxRuntime } from '@objectstack/core/security';
220
+
221
+ const sandbox = new PluginSandboxRuntime(logger);
222
+
223
+ // Create sandbox
224
+ const context = sandbox.createSandbox('my-plugin', {
225
+ enabled: true,
226
+ level: 'standard',
227
+ filesystem: {
228
+ mode: 'restricted',
229
+ allowedPaths: ['/app/plugins/my-plugin'],
230
+ deniedPaths: ['/etc', '/root'],
231
+ },
232
+ network: {
233
+ mode: 'restricted',
234
+ allowedHosts: ['api.example.com'],
235
+ blockedHosts: ['malicious.com'],
236
+ maxConnections: 10,
237
+ },
238
+ process: {
239
+ allowSpawn: false,
240
+ },
241
+ memory: {
242
+ maxHeap: 100 * 1024 * 1024, // 100 MB
243
+ },
244
+ });
245
+
246
+ // Check resource access
247
+ const fileAccess = sandbox.checkResourceAccess(
248
+ 'my-plugin',
249
+ 'file',
250
+ '/app/plugins/my-plugin/data.json'
251
+ );
252
+
253
+ const netAccess = sandbox.checkResourceAccess(
254
+ 'my-plugin',
255
+ 'network',
256
+ 'https://api.example.com/data'
257
+ );
258
+
259
+ // Check resource limits
260
+ const { withinLimits, violations } = sandbox.checkResourceLimits('my-plugin');
261
+
262
+ // Get resource usage
263
+ const usage = sandbox.getResourceUsage('my-plugin');
264
+ ```
265
+
266
+ ### 6. Security Scanner (`security/security-scanner.ts`)
267
+
268
+ The Security Scanner performs comprehensive security analysis of plugins.
269
+
270
+ **Features:**
271
+ - Code vulnerability scanning
272
+ - Dependency vulnerability detection (CVE database integration)
273
+ - Malware pattern detection
274
+ - License compliance checking
275
+ - Configuration security analysis
276
+ - Security scoring (0-100)
277
+ - Issue categorization (critical, high, medium, low, info)
278
+
279
+ **Usage:**
280
+
281
+ ```typescript
282
+ import { PluginSecurityScanner } from '@objectstack/core/security';
283
+
284
+ const scanner = new PluginSecurityScanner(logger);
285
+
286
+ // Perform security scan
287
+ const result = await scanner.scan({
288
+ pluginId: 'my-plugin',
289
+ version: '1.0.0',
290
+ files: ['src/**/*.ts'],
291
+ dependencies: {
292
+ 'express': '4.18.0',
293
+ 'lodash': '4.17.21',
294
+ },
295
+ });
296
+
297
+ console.log(`Security Score: ${result.score}/100`);
298
+ console.log(`Passed: ${result.passed}`);
299
+ console.log(`Issues:`, result.summary);
300
+
301
+ // Add vulnerability to database
302
+ scanner.addVulnerability('lodash', '4.17.20', {
303
+ cve: 'CVE-2021-23337',
304
+ severity: 'high',
305
+ affectedVersions: ['<=4.17.20'],
306
+ fixedIn: ['4.17.21'],
307
+ });
308
+
309
+ // Update vulnerability database
310
+ await scanner.updateVulnerabilityDatabase();
311
+ ```
312
+
313
+ ## Integration with Kernel
314
+
315
+ These components are designed to integrate with the existing ObjectKernel:
316
+
317
+ ```typescript
318
+ import {
319
+ ObjectKernel,
320
+ PluginHealthMonitor,
321
+ HotReloadManager,
322
+ DependencyResolver,
323
+ PluginPermissionManager,
324
+ PluginSandboxRuntime,
325
+ PluginSecurityScanner
326
+ } from '@objectstack/core';
327
+
328
+ const kernel = new ObjectKernel({ logger: { level: 'info' } });
329
+
330
+ // Initialize Phase 2 components
331
+ const healthMonitor = new PluginHealthMonitor(kernel.logger);
332
+ const hotReload = new HotReloadManager(kernel.logger);
333
+ const depResolver = new DependencyResolver(kernel.logger);
334
+ const permManager = new PluginPermissionManager(kernel.logger);
335
+ const sandbox = new PluginSandboxRuntime(kernel.logger);
336
+ const scanner = new PluginSecurityScanner(kernel.logger);
337
+
338
+ // Register plugins with enhanced features
339
+ // ... plugin registration code ...
340
+
341
+ // Bootstrap kernel
342
+ await kernel.bootstrap();
343
+ ```
344
+
345
+ ## Testing
346
+
347
+ Comprehensive unit tests are provided for all components:
348
+
349
+ - `health-monitor.test.ts` - Health monitoring tests
350
+ - `dependency-resolver.test.ts` - SemVer and dependency resolution tests
351
+ - `security/permission-manager.test.ts` - Permission management tests
352
+
353
+ Run tests with:
354
+
355
+ ```bash
356
+ npm test
357
+ ```
358
+
359
+ ## Performance Considerations
360
+
361
+ - Health checks run in separate intervals to avoid blocking
362
+ - State preservation uses checksums for integrity verification
363
+ - Dependency resolution uses efficient topological sorting
364
+ - Resource monitoring is throttled (default 5 seconds)
365
+ - Security scanning can be run asynchronously
366
+
367
+ ## Security
368
+
369
+ - All permissions must be explicitly granted
370
+ - Sandbox provides multiple isolation levels
371
+ - Security scanner integrates with CVE databases
372
+ - Resource limits prevent DoS attacks
373
+ - State preservation uses checksums to detect tampering
374
+
375
+ ## Future Enhancements
376
+
377
+ Phase 3 and beyond will add:
378
+ - Plugin marketplace integration
379
+ - AI-powered plugin development
380
+ - Enhanced monitoring and observability
381
+ - Distributed plugin management
382
+ - Advanced security features
383
+
384
+ ## References
385
+
386
+ - [MICROKERNEL_IMPROVEMENT_PLAN.md](../../MICROKERNEL_IMPROVEMENT_PLAN.md)
387
+ - [ARCHITECTURE.md](../../ARCHITECTURE.md)
388
+ - [Protocol Definitions](../spec/src/system/)
package/README.md CHANGED
@@ -13,6 +13,19 @@ This package defines the fundamental runtime mechanics of the ObjectStack archit
13
13
 
14
14
  It is completely agnostic of "Data", "HTTP", or "Apps". It only knows `Plugin` and `Service`.
15
15
 
16
+ ## 🤖 AI Development Context
17
+
18
+ **Role**: Microkernel / Runtime Orchestrator
19
+ **Usage**:
20
+ - Use `ObjectKernel` to bootstrap the application.
21
+ - Implement `Plugin` interface to add functionality (not business logic directly).
22
+ - Use `PluginLoader` features for dependency injection.
23
+
24
+ **Architectural Interaction**:
25
+ - `Kernel` loads `Plugins`.
26
+ - `Plugins` register `Services`.
27
+ - `Services` implement logic defined in `spec`.
28
+
16
29
  ## Features
17
30
 
18
31
  ### Core Features
@@ -254,15 +267,15 @@ kernel.use(apiPlugin);
254
267
  await kernel.bootstrap();
255
268
  ```
256
269
 
257
- ## Enhanced Kernel Usage
270
+ ## Advanced Kernel Usage
258
271
 
259
- For production applications, use `EnhancedObjectKernel` for advanced features:
272
+ For production applications, use `ObjectKernel` (formerly `EnhancedObjectKernel`) for advanced features:
260
273
 
261
274
  ```typescript
262
- import { EnhancedObjectKernel, PluginMetadata, ServiceLifecycle } from '@objectstack/core';
275
+ import { ObjectKernel, PluginMetadata, ServiceLifecycle } from '@objectstack/core';
263
276
 
264
- // Create enhanced kernel
265
- const kernel = new EnhancedObjectKernel({
277
+ // Create kernel with advanced configuration
278
+ const kernel = new ObjectKernel({
266
279
  logger: { level: 'info', format: 'pretty' },
267
280
  defaultStartupTimeout: 30000, // 30 seconds
268
281
  gracefulShutdown: true,
@@ -338,15 +351,15 @@ Automatic sensitive data redaction:
338
351
 
339
352
  ## API Reference
340
353
 
341
- ### ObjectKernel (Basic)
342
- - `ObjectKernel` - Basic microkernel class
354
+ ### LiteKernel (Minimal)
355
+ - `LiteKernel` - Lightweight microkernel for serverless/test
343
356
  - `createLogger(config)` - Create standalone logger
344
357
  - `Plugin` - Plugin interface
345
358
  - `PluginContext` - Runtime context for plugins
346
359
  - `Logger` - Logger interface
347
360
 
348
- ### EnhancedObjectKernel (Advanced)
349
- - `EnhancedObjectKernel` - Enhanced microkernel with production features
361
+ ### ObjectKernel (Production)
362
+ - `ObjectKernel` - Full-featured enterprise microkernel
350
363
  - `PluginLoader` - Plugin loading and validation
351
364
  - `ServiceLifecycle` - Service lifecycle management (SINGLETON, TRANSIENT, SCOPED)
352
365
  - `PluginMetadata` - Extended plugin interface with metadata
@@ -356,8 +369,8 @@ See [TypeScript definitions](./src/types.ts) for complete API.
356
369
 
357
370
  ## Documentation
358
371
 
359
- - [ENHANCED_FEATURES.md](./ENHANCED_FEATURES.md) - Comprehensive guide to enhanced features
360
- - [examples/enhanced-kernel-example.ts](./examples/enhanced-kernel-example.ts) - Complete working example
372
+ - [ADVANCED_FEATURES.md](./ADVANCED_FEATURES.md) - Comprehensive guide to kernel features
373
+ - [examples/kernel-features-example.ts](./examples/kernel-features-example.ts) - Complete working example
361
374
 
362
375
  ## License
363
376
 
@@ -0,0 +1,40 @@
1
+ # Kernel Refactoring Summary
2
+
3
+ This document summarizes the critical architectural improvements made to the `packages/core` module to address stability, performance, and correctness issues.
4
+
5
+ ## 1. Dependency Injection Context Fix
6
+ **Problem:** Service factories were receiving an empty object `{}` instead of the real `PluginContext`.
7
+ **Fix:**
8
+ - Updated `PluginLoader.createServiceInstance` to ensure `this.context` is passed to factories.
9
+ - Added `PluginLoader.setContext` method to inject the context from the Kernel.
10
+ - Kernel now properly injects itself and the loader into the context before initialization.
11
+
12
+ ## 2. Sync/Async Gap (Service Availability)
13
+ **Problem:** Services created asynchronously (via `awaitFactory`) were not accessible synchronously immediately after initialization, breaking code that expected `getService` to return an instance if the plugin was loaded.
14
+ **Fix:**
15
+ - Implemented L2 caching via `PluginLoader.getServiceInstance<T>(name: string)`.
16
+ - Kernel's `getService` now checks this synchronous cache first before falling back to the async path.
17
+ - Ensured singleton instances are stored in `serviceInstances` immediately upon creation.
18
+
19
+ ## 3. Runtime Circular Dependency Detection
20
+ **Problem:** Complex service graphs could deadlock or crash the stack if factories recursively requested each other. Static analysis was insufficient for dynamic factories.
21
+ **Fix:**
22
+ - Added a `creating` Set to `PluginLoader`.
23
+ - `createServiceInstance` now tracks which services are currently being built.
24
+ - Throws a descriptive error if a loop is detected (e.g., `Circular dependency detected: serviceA -> serviceB -> serviceA`).
25
+
26
+ ## 4. Enhanced Error Handling
27
+ **Problem:** The Kernel swallowed errors from service factories (like database connection failures) and threw a generic "Service not found" error, making debugging impossible.
28
+ **Fix:**
29
+ - Refined `Kernel.getService` to distinguish between "service registration missing" and "factory execution failed".
30
+ - Factory errors are now re-thrown with their original stack trace and message.
31
+
32
+ ## 5. Configuration Validation
33
+ **Problem:** Configuration validation was a scaffold without implementation.
34
+ **Fix:**
35
+ - Integrated `PluginConfigValidator` (Zod-based) into `PluginLoader`.
36
+ - `validatePluginConfig` now performs actual schema validation against `plugin.configSchema`.
37
+
38
+ ## Verification
39
+ - **Build:** Clean build of `dist` artifacts.
40
+ - **Tests:** 100% Pass rate (380/380 tests) across 22 test suites.