@@ -291,14 +291,26 @@ export const PluginDependencyResolutionSchema = z.object({
291291
292292/**
293293 * Plugin Hot Reload Configuration
294- * Enables hot module replacement for development
294+ * Enables hot module replacement for development and production environments.
295+ *
296+ * Production mode adds safety features: health validation, rollback on failure,
297+ * connection draining, and concurrency control for zero-downtime reloads.
295298 */
296299export const PluginHotReloadSchema = z . object ( {
297300 /**
298301 * Enable hot reload
299302 */
300303 enabled : z . boolean ( ) . default ( false ) ,
301304
305+ /**
306+ * Target environment for hot reload behavior
307+ */
308+ environment : z . enum ( [
309+ 'development' , // Fast reload with relaxed safety (file watchers, no health gates)
310+ 'staging' , // Production-like reload with validation but relaxed rollback
311+ 'production' , // Full safety: health gates, rollback, connection draining
312+ ] ) . default ( 'development' ) . describe ( 'Target environment controlling safety level' ) ,
313+
302314 /**
303315 * Hot reload strategy
304316 */
@@ -347,6 +359,54 @@ export const PluginHotReloadSchema = z.object({
347359 afterReload : z . string ( ) . optional ( ) . describe ( 'Function to call after reload' ) ,
348360 onError : z . string ( ) . optional ( ) . describe ( 'Function to call on reload error' ) ,
349361 } ) . optional ( ) ,
362+
363+ /**
364+ * Production safety configuration
365+ * Applied when environment is 'staging' or 'production'
366+ */
367+ productionSafety : z . object ( {
368+ /**
369+ * Validate plugin health before completing reload
370+ */
371+ healthValidation : z . boolean ( ) . default ( true )
372+ . describe ( 'Run health checks after reload before accepting traffic' ) ,
373+
374+ /**
375+ * Automatically rollback to previous version on reload failure
376+ */
377+ rollbackOnFailure : z . boolean ( ) . default ( true )
378+ . describe ( 'Auto-rollback if reloaded plugin fails health check' ) ,
379+
380+ /**
381+ * Maximum time to wait for health validation after reload (ms)
382+ */
383+ healthTimeout : z . number ( ) . int ( ) . min ( 1000 ) . default ( 30000 )
384+ . describe ( 'Health check timeout after reload in ms' ) ,
385+
386+ /**
387+ * Drain active connections before reload
388+ */
389+ drainConnections : z . boolean ( ) . default ( true )
390+ . describe ( 'Gracefully drain active requests before reloading' ) ,
391+
392+ /**
393+ * Maximum time to wait for connection draining (ms)
394+ */
395+ drainTimeout : z . number ( ) . int ( ) . min ( 0 ) . default ( 15000 )
396+ . describe ( 'Max wait time for connection draining in ms' ) ,
397+
398+ /**
399+ * Maximum number of concurrent plugin reloads
400+ */
401+ maxConcurrentReloads : z . number ( ) . int ( ) . min ( 1 ) . default ( 1 )
402+ . describe ( 'Limit concurrent reloads to prevent system instability' ) ,
403+
404+ /**
405+ * Minimum interval between reloads of the same plugin (ms)
406+ */
407+ minReloadInterval : z . number ( ) . int ( ) . min ( 0 ) . default ( 5000 )
408+ . describe ( 'Cooldown period between reloads of the same plugin' ) ,
409+ } ) . optional ( ) ,
350410} ) . describe ( 'Plugin hot reload configuration' ) ;
351411
352412/**
@@ -409,14 +469,26 @@ export const PluginCachingSchema = z.object({
409469
410470/**
411471 * Plugin Sandboxing Configuration
412- * Security isolation for untrusted plugins
472+ * Security isolation for plugins with configurable scope.
473+ *
474+ * Supports isolation beyond automation scripts: any plugin can be sandboxed
475+ * with process-level isolation and inter-plugin communication (IPC).
413476 */
414477export const PluginSandboxingSchema = z . object ( {
415478 /**
416479 * Enable sandboxing
417480 */
418481 enabled : z . boolean ( ) . default ( false ) ,
419482
483+ /**
484+ * Isolation scope - which plugins are subject to sandboxing
485+ */
486+ scope : z . enum ( [
487+ 'automation-only' , // Sandbox automation/scripting plugins only (current behavior)
488+ 'untrusted-only' , // Sandbox plugins below a trust threshold
489+ 'all-plugins' , // Sandbox all plugins (maximum isolation)
490+ ] ) . default ( 'automation-only' ) . describe ( 'Which plugins are subject to isolation' ) ,
491+
420492 /**
421493 * Sandbox isolation level
422494 */
@@ -482,6 +554,47 @@ export const PluginSandboxingSchema = z.object({
482554 */
483555 allowedEnvVars : z . array ( z . string ( ) ) . optional ( ) ,
484556 } ) . optional ( ) ,
557+
558+ /**
559+ * Inter-Plugin Communication (IPC) configuration
560+ * Enables isolated plugins to communicate with the kernel and other plugins
561+ */
562+ ipc : z . object ( {
563+ /**
564+ * Enable IPC for sandboxed plugins
565+ */
566+ enabled : z . boolean ( ) . default ( true )
567+ . describe ( 'Allow sandboxed plugins to communicate via IPC' ) ,
568+
569+ /**
570+ * IPC transport mechanism
571+ */
572+ transport : z . enum ( [
573+ 'message-port' , // MessagePort (worker threads / Web Workers)
574+ 'unix-socket' , // Unix domain sockets (process isolation)
575+ 'tcp' , // TCP sockets (container isolation)
576+ 'memory' , // Shared memory channel (in-process VM)
577+ ] ) . default ( 'message-port' )
578+ . describe ( 'IPC transport for cross-boundary communication' ) ,
579+
580+ /**
581+ * Maximum message size in bytes
582+ */
583+ maxMessageSize : z . number ( ) . int ( ) . min ( 1024 ) . default ( 1048576 )
584+ . describe ( 'Maximum IPC message size in bytes (default 1MB)' ) ,
585+
586+ /**
587+ * Message timeout in milliseconds
588+ */
589+ timeout : z . number ( ) . int ( ) . min ( 100 ) . default ( 30000 )
590+ . describe ( 'IPC message response timeout in ms' ) ,
591+
592+ /**
593+ * Allowed service calls through IPC
594+ */
595+ allowedServices : z . array ( z . string ( ) ) . optional ( )
596+ . describe ( 'Service names the sandboxed plugin may invoke via IPC' ) ,
597+ } ) . optional ( ) ,
485598} ) . describe ( 'Plugin sandboxing configuration' ) ;
486599
487600/**
@@ -579,7 +692,7 @@ export const PluginLoadingConfigSchema = z.object({
579692 dependencyResolution : PluginDependencyResolutionSchema . optional ( ) ,
580693
581694 /**
582- * Hot reload configuration (development only )
695+ * Hot reload configuration (development and production )
583696 */
584697 hotReload : PluginHotReloadSchema . optional ( ) ,
585698
@@ -619,6 +732,9 @@ export const PluginLoadingEventSchema = z.object({
619732 'cache-hit' ,
620733 'cache-miss' ,
621734 'hot-reload' ,
735+ 'dynamic-load' , // Plugin loaded at runtime
736+ 'dynamic-unload' , // Plugin unloaded at runtime
737+ 'dynamic-discover' , // Plugin discovered via registry
622738 ] ) ,
623739
624740 /**
@@ -672,6 +788,8 @@ export const PluginLoadingStateSchema = z.object({
672788 'ready' , // Fully initialized and ready
673789 'failed' , // Failed to load or initialize
674790 'reloading' , // Hot reloading in progress
791+ 'unloading' , // Being unloaded at runtime
792+ 'unloaded' , // Successfully unloaded (dynamic loading)
675793 ] ) ,
676794
677795 /**
0 commit comments