Plugin Lifecycle Advanced
Plugin Lifecycle Advanced protocol schemas
Defines advanced lifecycle management capabilities including:
- Hot reload and live updates
- Graceful degradation and fallback mechanisms
- Health monitoring and auto-recovery
- State preservation during updates
This protocol extends the basic plugin lifecycle with enterprise-grade
features for production environments.
Source: packages/spec/src/kernel/plugin-lifecycle-advanced.zod.ts
import { AdvancedPluginLifecycleConfigSchema, DistributedStateConfigSchema, GracefulDegradationSchema, HotReloadConfigSchema, PluginHealthCheckSchema, PluginHealthReportSchema, PluginHealthStatusSchema, PluginStateSnapshotSchema, PluginUpdateStrategySchema } from '@objectstack/spec/kernel';
import type { AdvancedPluginLifecycleConfig, DistributedStateConfig, GracefulDegradation, HotReloadConfig, PluginHealthCheck, PluginHealthReport, PluginHealthStatus, PluginStateSnapshot, PluginUpdateStrategy } from '@objectstack/spec/kernel';
// Validate data
const result = AdvancedPluginLifecycleConfigSchema.parse(data);
| Property | Type | Required | Description |
|---|
| health | { interval: integer; timeout: integer; failureThreshold: integer; successThreshold: integer; … } | optional | |
| hotReload | { enabled: boolean; watchPatterns?: string[]; debounceDelay: integer; preserveState: boolean; … } | optional | |
| degradation | { enabled: boolean; fallbackMode: Enum<'minimal' | 'cached' | 'readonly' | 'offline' | 'disabled'>; criticalDependencies?: string[]; optionalDependencies?: string[]; … } | optional | |
| updates | { mode: Enum<'manual' | 'automatic' | 'scheduled' | 'rolling'>; autoUpdateConstraints?: object; schedule?: object; rollback?: object; … } | optional | |
| resources | { maxMemory?: integer; maxCpu?: number; maxConnections?: integer; timeout?: integer } | optional | |
| observability | { enableMetrics: boolean; enableTracing: boolean; enableProfiling: boolean; metricsInterval: integer } | optional | |
| Property | Type | Required | Description |
|---|
| provider | Enum<'redis' | 'etcd' | 'custom'> | ✅ | Distributed state backend provider |
| endpoints | string[] | optional | Backend connection endpoints |
| keyPrefix | string | optional | Prefix for all keys (e.g., "plugin:my-plugin:") |
| ttl | integer | optional | State expiration time in seconds |
| auth | { username?: string; password?: string; token?: string; certificate?: string } | optional | |
| replication | { enabled: boolean; minReplicas: integer } | optional | |
| customConfig | Record<string, any> | optional | Provider-specific configuration |
| Property | Type | Required | Description |
|---|
| enabled | boolean | ✅ | |
| fallbackMode | Enum<'minimal' | 'cached' | 'readonly' | 'offline' | 'disabled'> | ✅ | |
| criticalDependencies | string[] | optional | Plugin IDs that are required for operation |
| optionalDependencies | string[] | optional | Plugin IDs that are nice to have but not required |
| degradedFeatures | { feature: string; enabled: boolean; reason?: string }[] | optional | |
| autoRecovery | { enabled: boolean; retryInterval: integer; maxAttempts: integer } | optional | |
| Property | Type | Required | Description |
|---|
| enabled | boolean | ✅ | |
| watchPatterns | string[] | optional | Glob patterns to watch for changes |
| debounceDelay | integer | ✅ | Wait time after change detection before reload |
| preserveState | boolean | ✅ | Keep plugin state across reloads |
| stateStrategy | Enum<'memory' | 'disk' | 'distributed' | 'none'> | ✅ | How to preserve state during reload |
| distributedConfig | { provider: Enum<'redis' | 'etcd' | 'custom'>; endpoints?: string[]; keyPrefix?: string; ttl?: integer; … } | optional | Configuration for distributed state management |
| shutdownTimeout | integer | ✅ | Maximum time to wait for graceful shutdown |
| beforeReload | string[] | optional | Hook names to call before reload |
| afterReload | string[] | optional | Hook names to call after reload |
| Property | Type | Required | Description |
|---|
| interval | integer | ✅ | How often to perform health checks (default: 30s) |
| timeout | integer | ✅ | Maximum time to wait for health check response |
| failureThreshold | integer | ✅ | Consecutive failures needed to mark unhealthy |
| successThreshold | integer | ✅ | Consecutive successes needed to mark healthy |
| checkMethod | string | optional | Method name to call for health check |
| autoRestart | boolean | ✅ | Automatically restart plugin on health check failure |
| maxRestartAttempts | integer | ✅ | Maximum restart attempts before giving up |
| restartBackoff | Enum<'fixed' | 'linear' | 'exponential'> | ✅ | Backoff strategy for restart delays |
| Property | Type | Required | Description |
|---|
| status | Enum<'healthy' | 'degraded' | 'unhealthy' | 'failed' | 'recovering' | 'unknown'> | ✅ | Current health status of the plugin |
| timestamp | string | ✅ | |
| message | string | optional | |
| metrics | { uptime?: number; memoryUsage?: number; cpuUsage?: number; activeConnections?: number; … } | optional | |
| checks | { name: string; status: Enum<'passed' | 'failed' | 'warning'>; message?: string; data?: Record<string, any> }[] | optional | |
| dependencies | { pluginId: string; status: Enum<'healthy' | 'degraded' | 'unhealthy' | 'failed' | 'recovering' | 'unknown'>; message?: string }[] | optional | |
Current health status of the plugin
healthy
degraded
unhealthy
failed
recovering
unknown
| Property | Type | Required | Description |
|---|
| pluginId | string | ✅ | |
| version | string | ✅ | |
| timestamp | string | ✅ | |
| state | Record<string, any> | ✅ | |
| metadata | { checksum?: string; compressed: boolean; encryption?: string } | optional | |
| Property | Type | Required | Description |
|---|
| mode | Enum<'manual' | 'automatic' | 'scheduled' | 'rolling'> | ✅ | |
| autoUpdateConstraints | { major: boolean; minor: boolean; patch: boolean } | optional | |
| schedule | { cron?: string; timezone: string; maintenanceWindow: integer } | optional | |
| rollback | { enabled: boolean; automatic: boolean; keepVersions: integer; timeout: integer } | optional | |
| validation | { checkCompatibility: boolean; runTests: boolean; testSuite?: string } | optional | |