claude-mpm 0.3.0__py3-none-any.whl

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.

Potentially problematic release.


This version of claude-mpm might be problematic. Click here for more details.

Files changed (159) hide show
  1. claude_mpm/__init__.py +17 -0
  2. claude_mpm/__main__.py +14 -0
  3. claude_mpm/_version.py +32 -0
  4. claude_mpm/agents/BASE_AGENT_TEMPLATE.md +88 -0
  5. claude_mpm/agents/INSTRUCTIONS.md +375 -0
  6. claude_mpm/agents/__init__.py +118 -0
  7. claude_mpm/agents/agent_loader.py +621 -0
  8. claude_mpm/agents/agent_loader_integration.py +229 -0
  9. claude_mpm/agents/agents_metadata.py +204 -0
  10. claude_mpm/agents/base_agent.json +27 -0
  11. claude_mpm/agents/base_agent_loader.py +519 -0
  12. claude_mpm/agents/schema/agent_schema.json +160 -0
  13. claude_mpm/agents/system_agent_config.py +587 -0
  14. claude_mpm/agents/templates/__init__.py +101 -0
  15. claude_mpm/agents/templates/data_engineer_agent.json +46 -0
  16. claude_mpm/agents/templates/documentation_agent.json +45 -0
  17. claude_mpm/agents/templates/engineer_agent.json +49 -0
  18. claude_mpm/agents/templates/ops_agent.json +46 -0
  19. claude_mpm/agents/templates/qa_agent.json +45 -0
  20. claude_mpm/agents/templates/research_agent.json +49 -0
  21. claude_mpm/agents/templates/security_agent.json +46 -0
  22. claude_mpm/agents/templates/update-optimized-specialized-agents.json +374 -0
  23. claude_mpm/agents/templates/version_control_agent.json +46 -0
  24. claude_mpm/agents/test_fix_deployment/.claude-pm/config/project.json +6 -0
  25. claude_mpm/cli.py +655 -0
  26. claude_mpm/cli_main.py +13 -0
  27. claude_mpm/cli_module/__init__.py +15 -0
  28. claude_mpm/cli_module/args.py +222 -0
  29. claude_mpm/cli_module/commands.py +203 -0
  30. claude_mpm/cli_module/migration_example.py +183 -0
  31. claude_mpm/cli_module/refactoring_guide.md +253 -0
  32. claude_mpm/cli_old/__init__.py +1 -0
  33. claude_mpm/cli_old/ticket_cli.py +102 -0
  34. claude_mpm/config/__init__.py +5 -0
  35. claude_mpm/config/hook_config.py +42 -0
  36. claude_mpm/constants.py +150 -0
  37. claude_mpm/core/__init__.py +45 -0
  38. claude_mpm/core/agent_name_normalizer.py +248 -0
  39. claude_mpm/core/agent_registry.py +627 -0
  40. claude_mpm/core/agent_registry.py.bak +312 -0
  41. claude_mpm/core/agent_session_manager.py +273 -0
  42. claude_mpm/core/base_service.py +747 -0
  43. claude_mpm/core/base_service.py.bak +406 -0
  44. claude_mpm/core/config.py +334 -0
  45. claude_mpm/core/config_aliases.py +292 -0
  46. claude_mpm/core/container.py +347 -0
  47. claude_mpm/core/factories.py +281 -0
  48. claude_mpm/core/framework_loader.py +472 -0
  49. claude_mpm/core/injectable_service.py +206 -0
  50. claude_mpm/core/interfaces.py +539 -0
  51. claude_mpm/core/logger.py +468 -0
  52. claude_mpm/core/minimal_framework_loader.py +107 -0
  53. claude_mpm/core/mixins.py +150 -0
  54. claude_mpm/core/service_registry.py +299 -0
  55. claude_mpm/core/session_manager.py +190 -0
  56. claude_mpm/core/simple_runner.py +511 -0
  57. claude_mpm/core/tool_access_control.py +173 -0
  58. claude_mpm/hooks/README.md +243 -0
  59. claude_mpm/hooks/__init__.py +5 -0
  60. claude_mpm/hooks/base_hook.py +154 -0
  61. claude_mpm/hooks/builtin/__init__.py +1 -0
  62. claude_mpm/hooks/builtin/logging_hook_example.py +165 -0
  63. claude_mpm/hooks/builtin/post_delegation_hook_example.py +124 -0
  64. claude_mpm/hooks/builtin/pre_delegation_hook_example.py +125 -0
  65. claude_mpm/hooks/builtin/submit_hook_example.py +100 -0
  66. claude_mpm/hooks/builtin/ticket_extraction_hook_example.py +237 -0
  67. claude_mpm/hooks/builtin/todo_agent_prefix_hook.py +239 -0
  68. claude_mpm/hooks/builtin/workflow_start_hook.py +181 -0
  69. claude_mpm/hooks/hook_client.py +264 -0
  70. claude_mpm/hooks/hook_runner.py +370 -0
  71. claude_mpm/hooks/json_rpc_executor.py +259 -0
  72. claude_mpm/hooks/json_rpc_hook_client.py +319 -0
  73. claude_mpm/hooks/tool_call_interceptor.py +204 -0
  74. claude_mpm/init.py +246 -0
  75. claude_mpm/orchestration/SUBPROCESS_DESIGN.md +66 -0
  76. claude_mpm/orchestration/__init__.py +6 -0
  77. claude_mpm/orchestration/archive/direct_orchestrator.py +195 -0
  78. claude_mpm/orchestration/archive/factory.py +215 -0
  79. claude_mpm/orchestration/archive/hook_enabled_orchestrator.py +188 -0
  80. claude_mpm/orchestration/archive/hook_integration_example.py +178 -0
  81. claude_mpm/orchestration/archive/interactive_subprocess_orchestrator.py +826 -0
  82. claude_mpm/orchestration/archive/orchestrator.py +501 -0
  83. claude_mpm/orchestration/archive/pexpect_orchestrator.py +252 -0
  84. claude_mpm/orchestration/archive/pty_orchestrator.py +270 -0
  85. claude_mpm/orchestration/archive/simple_orchestrator.py +82 -0
  86. claude_mpm/orchestration/archive/subprocess_orchestrator.py +801 -0
  87. claude_mpm/orchestration/archive/system_prompt_orchestrator.py +278 -0
  88. claude_mpm/orchestration/archive/wrapper_orchestrator.py +187 -0
  89. claude_mpm/scripts/__init__.py +1 -0
  90. claude_mpm/scripts/ticket.py +269 -0
  91. claude_mpm/services/__init__.py +10 -0
  92. claude_mpm/services/agent_deployment.py +955 -0
  93. claude_mpm/services/agent_lifecycle_manager.py +948 -0
  94. claude_mpm/services/agent_management_service.py +596 -0
  95. claude_mpm/services/agent_modification_tracker.py +841 -0
  96. claude_mpm/services/agent_profile_loader.py +606 -0
  97. claude_mpm/services/agent_registry.py +677 -0
  98. claude_mpm/services/base_agent_manager.py +380 -0
  99. claude_mpm/services/framework_agent_loader.py +337 -0
  100. claude_mpm/services/framework_claude_md_generator/README.md +92 -0
  101. claude_mpm/services/framework_claude_md_generator/__init__.py +206 -0
  102. claude_mpm/services/framework_claude_md_generator/content_assembler.py +151 -0
  103. claude_mpm/services/framework_claude_md_generator/content_validator.py +126 -0
  104. claude_mpm/services/framework_claude_md_generator/deployment_manager.py +137 -0
  105. claude_mpm/services/framework_claude_md_generator/section_generators/__init__.py +106 -0
  106. claude_mpm/services/framework_claude_md_generator/section_generators/agents.py +582 -0
  107. claude_mpm/services/framework_claude_md_generator/section_generators/claude_pm_init.py +97 -0
  108. claude_mpm/services/framework_claude_md_generator/section_generators/core_responsibilities.py +27 -0
  109. claude_mpm/services/framework_claude_md_generator/section_generators/delegation_constraints.py +23 -0
  110. claude_mpm/services/framework_claude_md_generator/section_generators/environment_config.py +23 -0
  111. claude_mpm/services/framework_claude_md_generator/section_generators/footer.py +20 -0
  112. claude_mpm/services/framework_claude_md_generator/section_generators/header.py +26 -0
  113. claude_mpm/services/framework_claude_md_generator/section_generators/orchestration_principles.py +30 -0
  114. claude_mpm/services/framework_claude_md_generator/section_generators/role_designation.py +37 -0
  115. claude_mpm/services/framework_claude_md_generator/section_generators/subprocess_validation.py +111 -0
  116. claude_mpm/services/framework_claude_md_generator/section_generators/todo_task_tools.py +89 -0
  117. claude_mpm/services/framework_claude_md_generator/section_generators/troubleshooting.py +39 -0
  118. claude_mpm/services/framework_claude_md_generator/section_manager.py +106 -0
  119. claude_mpm/services/framework_claude_md_generator/version_manager.py +121 -0
  120. claude_mpm/services/framework_claude_md_generator.py +621 -0
  121. claude_mpm/services/hook_service.py +388 -0
  122. claude_mpm/services/hook_service_manager.py +223 -0
  123. claude_mpm/services/json_rpc_hook_manager.py +92 -0
  124. claude_mpm/services/parent_directory_manager/README.md +83 -0
  125. claude_mpm/services/parent_directory_manager/__init__.py +577 -0
  126. claude_mpm/services/parent_directory_manager/backup_manager.py +258 -0
  127. claude_mpm/services/parent_directory_manager/config_manager.py +210 -0
  128. claude_mpm/services/parent_directory_manager/deduplication_manager.py +279 -0
  129. claude_mpm/services/parent_directory_manager/framework_protector.py +143 -0
  130. claude_mpm/services/parent_directory_manager/operations.py +186 -0
  131. claude_mpm/services/parent_directory_manager/state_manager.py +624 -0
  132. claude_mpm/services/parent_directory_manager/template_deployer.py +579 -0
  133. claude_mpm/services/parent_directory_manager/validation_manager.py +378 -0
  134. claude_mpm/services/parent_directory_manager/version_control_helper.py +339 -0
  135. claude_mpm/services/parent_directory_manager/version_manager.py +222 -0
  136. claude_mpm/services/shared_prompt_cache.py +819 -0
  137. claude_mpm/services/ticket_manager.py +213 -0
  138. claude_mpm/services/ticket_manager_di.py +318 -0
  139. claude_mpm/services/ticketing_service_original.py +508 -0
  140. claude_mpm/services/version_control/VERSION +1 -0
  141. claude_mpm/services/version_control/__init__.py +70 -0
  142. claude_mpm/services/version_control/branch_strategy.py +670 -0
  143. claude_mpm/services/version_control/conflict_resolution.py +744 -0
  144. claude_mpm/services/version_control/git_operations.py +784 -0
  145. claude_mpm/services/version_control/semantic_versioning.py +703 -0
  146. claude_mpm/ui/__init__.py +1 -0
  147. claude_mpm/ui/rich_terminal_ui.py +295 -0
  148. claude_mpm/ui/terminal_ui.py +328 -0
  149. claude_mpm/utils/__init__.py +16 -0
  150. claude_mpm/utils/config_manager.py +468 -0
  151. claude_mpm/utils/import_migration_example.py +80 -0
  152. claude_mpm/utils/imports.py +182 -0
  153. claude_mpm/utils/path_operations.py +357 -0
  154. claude_mpm/utils/paths.py +289 -0
  155. claude_mpm-0.3.0.dist-info/METADATA +290 -0
  156. claude_mpm-0.3.0.dist-info/RECORD +159 -0
  157. claude_mpm-0.3.0.dist-info/WHEEL +5 -0
  158. claude_mpm-0.3.0.dist-info/entry_points.txt +4 -0
  159. claude_mpm-0.3.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,539 @@
1
+ """
2
+ Core Service Interfaces for Claude PM Framework
3
+ ==============================================
4
+
5
+ This module defines the core service interfaces that establish contracts for
6
+ dependency injection, service discovery, and framework orchestration.
7
+
8
+ Phase 1 Refactoring: Interface extraction and dependency injection foundation
9
+ - IServiceContainer: Dependency injection container
10
+ - IAgentRegistry: Agent discovery and management
11
+ - IPromptCache: Performance-critical caching
12
+ - IHealthMonitor: Service health monitoring
13
+ - IConfigurationManager: Configuration management
14
+ - ITemplateManager: Template processing and rendering
15
+ - IServiceFactory: Service creation patterns
16
+
17
+ These interfaces reduce cyclomatic complexity and establish clean separation of concerns.
18
+ """
19
+
20
+ from abc import ABC, abstractmethod
21
+ from typing import Any, Dict, List, Optional, Set, Tuple, Union, TypeVar, Generic
22
+ from dataclasses import dataclass
23
+ from datetime import datetime
24
+ from pathlib import Path
25
+ import asyncio
26
+
27
+ # Type variables for generic interfaces
28
+ T = TypeVar('T')
29
+ ServiceType = TypeVar('ServiceType')
30
+
31
+
32
+ # Core dependency injection interfaces
33
+ class IServiceContainer(ABC):
34
+ """Service container interface for dependency injection"""
35
+
36
+ @abstractmethod
37
+ def register(self, service_type: type, implementation: type, singleton: bool = True) -> None:
38
+ """Register a service implementation"""
39
+ pass
40
+
41
+ @abstractmethod
42
+ def register_instance(self, service_type: type, instance: Any) -> None:
43
+ """Register a service instance"""
44
+ pass
45
+
46
+ @abstractmethod
47
+ def resolve(self, service_type: type) -> Any:
48
+ """Resolve a service by type"""
49
+ pass
50
+
51
+ @abstractmethod
52
+ def resolve_all(self, service_type: type) -> List[Any]:
53
+ """Resolve all implementations of a service type"""
54
+ pass
55
+
56
+ @abstractmethod
57
+ def is_registered(self, service_type: type) -> bool:
58
+ """Check if a service type is registered"""
59
+ pass
60
+
61
+
62
+ # Configuration management interfaces
63
+ class IConfigurationService(ABC):
64
+ """Interface for configuration service (legacy compatibility)"""
65
+
66
+ @abstractmethod
67
+ def get(self, key: str, default: Any = None) -> Any:
68
+ """Get configuration value by key"""
69
+ pass
70
+
71
+ @abstractmethod
72
+ def set(self, key: str, value: Any) -> None:
73
+ """Set configuration value"""
74
+ pass
75
+
76
+ @abstractmethod
77
+ def initialize(self) -> bool:
78
+ """Initialize configuration service"""
79
+ pass
80
+
81
+ @abstractmethod
82
+ def shutdown(self) -> None:
83
+ """Shutdown configuration service"""
84
+ pass
85
+
86
+ class IConfigurationManager(ABC):
87
+ """Interface for configuration management and validation"""
88
+
89
+ @abstractmethod
90
+ def get(self, key: str, default: Any = None) -> Any:
91
+ """Get configuration value by key"""
92
+ pass
93
+
94
+ @abstractmethod
95
+ def set(self, key: str, value: Any) -> None:
96
+ """Set configuration value"""
97
+ pass
98
+
99
+ @abstractmethod
100
+ def get_section(self, section: str) -> Dict[str, Any]:
101
+ """Get entire configuration section"""
102
+ pass
103
+
104
+ @abstractmethod
105
+ def validate_schema(self, schema: Dict[str, Any]) -> bool:
106
+ """Validate configuration against schema"""
107
+ pass
108
+
109
+ @abstractmethod
110
+ def reload(self) -> None:
111
+ """Reload configuration from sources"""
112
+ pass
113
+
114
+ @abstractmethod
115
+ def watch_changes(self, callback: callable) -> None:
116
+ """Watch for configuration changes"""
117
+ pass
118
+
119
+
120
+ # Cache service interface
121
+ class ICacheService(ABC):
122
+ """Interface for cache service operations"""
123
+
124
+ @abstractmethod
125
+ def get(self, key: str) -> Any:
126
+ """Get value from cache"""
127
+ pass
128
+
129
+ @abstractmethod
130
+ def set(self, key: str, value: Any, ttl: Optional[int] = None) -> None:
131
+ """Set value in cache with optional TTL"""
132
+ pass
133
+
134
+ @abstractmethod
135
+ def delete(self, key: str) -> bool:
136
+ """Delete key from cache"""
137
+ pass
138
+
139
+ @abstractmethod
140
+ def invalidate(self, pattern: str) -> int:
141
+ """Invalidate keys matching pattern"""
142
+ pass
143
+
144
+ @abstractmethod
145
+ def clear(self) -> None:
146
+ """Clear all cache entries"""
147
+ pass
148
+
149
+ @abstractmethod
150
+ def get_cache_metrics(self) -> Dict[str, Any]:
151
+ """Get cache performance metrics"""
152
+ pass
153
+
154
+
155
+ # Health monitoring interface
156
+ @dataclass
157
+ class HealthStatus:
158
+ """Health status data structure"""
159
+ status: str # healthy, degraded, unhealthy, unknown
160
+ message: str
161
+ timestamp: datetime
162
+ checks: Dict[str, bool]
163
+ metrics: Dict[str, Any]
164
+
165
+
166
+ class IHealthMonitor(ABC):
167
+ """Interface for service health monitoring"""
168
+
169
+ @abstractmethod
170
+ async def check_health(self, service_name: str) -> HealthStatus:
171
+ """Check health of a specific service"""
172
+ pass
173
+
174
+ @abstractmethod
175
+ async def get_system_health(self) -> HealthStatus:
176
+ """Get overall system health"""
177
+ pass
178
+
179
+ @abstractmethod
180
+ def register_health_check(self, service_name: str, check_func: callable) -> None:
181
+ """Register a health check function"""
182
+ pass
183
+
184
+ @abstractmethod
185
+ async def start_monitoring(self) -> None:
186
+ """Start health monitoring"""
187
+ pass
188
+
189
+ @abstractmethod
190
+ async def stop_monitoring(self) -> None:
191
+ """Stop health monitoring"""
192
+ pass
193
+
194
+
195
+ # Agent registry interface
196
+ @dataclass
197
+ class AgentMetadata:
198
+ """Enhanced agent metadata with specialization and model configuration support"""
199
+ name: str
200
+ type: str
201
+ path: str
202
+ tier: str
203
+ description: Optional[str] = None
204
+ version: Optional[str] = None
205
+ capabilities: List[str] = None
206
+ specializations: List[str] = None
207
+ frameworks: List[str] = None
208
+ domains: List[str] = None
209
+ roles: List[str] = None
210
+ is_hybrid: bool = False
211
+ validation_score: float = 0.0
212
+ last_modified: Optional[float] = None
213
+ # Model configuration fields
214
+ preferred_model: Optional[str] = None
215
+ model_config: Optional[Dict[str, Any]] = None
216
+
217
+ def __post_init__(self):
218
+ """Initialize default values for list fields"""
219
+ if self.capabilities is None:
220
+ self.capabilities = []
221
+ if self.specializations is None:
222
+ self.specializations = []
223
+ if self.frameworks is None:
224
+ self.frameworks = []
225
+ if self.domains is None:
226
+ self.domains = []
227
+ if self.roles is None:
228
+ self.roles = []
229
+ if self.model_config is None:
230
+ self.model_config = {}
231
+
232
+
233
+ class IAgentRegistry(ABC):
234
+ """Interface for agent discovery and management"""
235
+
236
+ @abstractmethod
237
+ async def discover_agents(self, force_refresh: bool = False) -> Dict[str, AgentMetadata]:
238
+ """Discover all available agents"""
239
+ pass
240
+
241
+ @abstractmethod
242
+ async def get_agent(self, agent_name: str) -> Optional[AgentMetadata]:
243
+ """Get specific agent metadata"""
244
+ pass
245
+
246
+ @abstractmethod
247
+ async def list_agents(self, agent_type: Optional[str] = None, tier: Optional[str] = None) -> List[AgentMetadata]:
248
+ """List agents with optional filtering"""
249
+ pass
250
+
251
+ @abstractmethod
252
+ async def get_specialized_agents(self, agent_type: str) -> List[AgentMetadata]:
253
+ """Get agents of a specific specialized type"""
254
+ pass
255
+
256
+ @abstractmethod
257
+ async def search_by_capability(self, capability: str) -> List[AgentMetadata]:
258
+ """Search agents by capability"""
259
+ pass
260
+
261
+ @abstractmethod
262
+ async def get_registry_stats(self) -> Dict[str, Any]:
263
+ """Get registry statistics"""
264
+ pass
265
+
266
+
267
+ # Prompt cache interface
268
+ @dataclass
269
+ class CacheEntry:
270
+ """Cache entry with metadata"""
271
+ key: str
272
+ value: Any
273
+ created_at: float
274
+ ttl: Optional[float] = None
275
+ access_count: int = 0
276
+ last_accessed: float = 0.0
277
+ size_bytes: int = 0
278
+ metadata: Dict[str, Any] = None
279
+
280
+ def __post_init__(self):
281
+ if self.metadata is None:
282
+ self.metadata = {}
283
+
284
+
285
+ class IPromptCache(ABC):
286
+ """Interface for high-performance prompt caching"""
287
+
288
+ @abstractmethod
289
+ def get(self, key: str) -> Optional[Any]:
290
+ """Get cached value by key"""
291
+ pass
292
+
293
+ @abstractmethod
294
+ def set(self, key: str, value: Any, ttl: Optional[float] = None, metadata: Optional[Dict[str, Any]] = None) -> bool:
295
+ """Set cached value with optional TTL"""
296
+ pass
297
+
298
+ @abstractmethod
299
+ def delete(self, key: str) -> bool:
300
+ """Delete cached value"""
301
+ pass
302
+
303
+ @abstractmethod
304
+ def invalidate(self, pattern: str) -> int:
305
+ """Invalidate cached values matching pattern"""
306
+ pass
307
+
308
+ @abstractmethod
309
+ def clear(self) -> None:
310
+ """Clear all cached values"""
311
+ pass
312
+
313
+ @abstractmethod
314
+ def get_metrics(self) -> Dict[str, Any]:
315
+ """Get cache performance metrics"""
316
+ pass
317
+
318
+
319
+ # Template management interface
320
+ @dataclass
321
+ class TemplateRenderContext:
322
+ """Context for template rendering"""
323
+ variables: Dict[str, Any]
324
+ metadata: Dict[str, Any]
325
+ target_path: Optional[Path] = None
326
+ template_id: Optional[str] = None
327
+
328
+
329
+ class ITemplateManager(ABC):
330
+ """Interface for template processing and rendering"""
331
+
332
+ @abstractmethod
333
+ async def render_template(self, template_content: str, context: TemplateRenderContext) -> str:
334
+ """Render template with given context"""
335
+ pass
336
+
337
+ @abstractmethod
338
+ async def load_template(self, template_id: str) -> Optional[str]:
339
+ """Load template by ID"""
340
+ pass
341
+
342
+ @abstractmethod
343
+ async def validate_template(self, template_content: str) -> Tuple[bool, List[str]]:
344
+ """Validate template syntax and variables"""
345
+ pass
346
+
347
+ @abstractmethod
348
+ def register_template_function(self, name: str, func: callable) -> None:
349
+ """Register custom template function"""
350
+ pass
351
+
352
+
353
+ # Service factory interface
354
+ class IServiceFactory(Generic[ServiceType], ABC):
355
+ """Generic interface for service factories"""
356
+
357
+ @abstractmethod
358
+ def create(self, **kwargs) -> ServiceType:
359
+ """Create service instance"""
360
+ pass
361
+
362
+ @abstractmethod
363
+ def create_with_config(self, config: Dict[str, Any]) -> ServiceType:
364
+ """Create service instance with configuration"""
365
+ pass
366
+
367
+ @abstractmethod
368
+ def supports_type(self, service_type: type) -> bool:
369
+ """Check if factory supports service type"""
370
+ pass
371
+
372
+
373
+ # Logging interface
374
+ class IStructuredLogger(ABC):
375
+ """Interface for structured logging"""
376
+
377
+ @abstractmethod
378
+ def debug(self, message: str, **kwargs) -> None:
379
+ """Log debug message with structured data"""
380
+ pass
381
+
382
+ @abstractmethod
383
+ def info(self, message: str, **kwargs) -> None:
384
+ """Log info message with structured data"""
385
+ pass
386
+
387
+ @abstractmethod
388
+ def warning(self, message: str, **kwargs) -> None:
389
+ """Log warning message with structured data"""
390
+ pass
391
+
392
+ @abstractmethod
393
+ def error(self, message: str, **kwargs) -> None:
394
+ """Log error message with structured data"""
395
+ pass
396
+
397
+ @abstractmethod
398
+ def critical(self, message: str, **kwargs) -> None:
399
+ """Log critical message with structured data"""
400
+ pass
401
+
402
+ @abstractmethod
403
+ def set_context(self, **kwargs) -> None:
404
+ """Set logging context for all subsequent messages"""
405
+ pass
406
+
407
+
408
+ # Service lifecycle interface
409
+ class IServiceLifecycle(ABC):
410
+ """Interface for service lifecycle management"""
411
+
412
+ @abstractmethod
413
+ async def initialize(self) -> None:
414
+ """Initialize the service"""
415
+ pass
416
+
417
+ @abstractmethod
418
+ async def start(self) -> None:
419
+ """Start the service"""
420
+ pass
421
+
422
+ @abstractmethod
423
+ async def stop(self) -> None:
424
+ """Stop the service"""
425
+ pass
426
+
427
+ @abstractmethod
428
+ async def restart(self) -> None:
429
+ """Restart the service"""
430
+ pass
431
+
432
+ @abstractmethod
433
+ def is_running(self) -> bool:
434
+ """Check if service is running"""
435
+ pass
436
+
437
+
438
+ # Error handling interface
439
+ class IErrorHandler(ABC):
440
+ """Interface for centralized error handling"""
441
+
442
+ @abstractmethod
443
+ def handle_error(self, error: Exception, context: Dict[str, Any]) -> None:
444
+ """Handle error with context"""
445
+ pass
446
+
447
+ @abstractmethod
448
+ def register_error_handler(self, error_type: type, handler: callable) -> None:
449
+ """Register error handler for specific error type"""
450
+ pass
451
+
452
+ @abstractmethod
453
+ def get_error_stats(self) -> Dict[str, Any]:
454
+ """Get error statistics"""
455
+ pass
456
+
457
+
458
+ # Performance monitoring interface
459
+ class IPerformanceMonitor(ABC):
460
+ """Interface for performance monitoring"""
461
+
462
+ @abstractmethod
463
+ def start_timer(self, operation: str) -> str:
464
+ """Start timing an operation"""
465
+ pass
466
+
467
+ @abstractmethod
468
+ def stop_timer(self, timer_id: str) -> float:
469
+ """Stop timing and return duration"""
470
+ pass
471
+
472
+ @abstractmethod
473
+ def record_metric(self, name: str, value: float, tags: Optional[Dict[str, str]] = None) -> None:
474
+ """Record a performance metric"""
475
+ pass
476
+
477
+ @abstractmethod
478
+ def get_metrics(self) -> Dict[str, Any]:
479
+ """Get performance metrics"""
480
+ pass
481
+
482
+
483
+ # Event system interface
484
+ class IEventBus(ABC):
485
+ """Interface for event-driven communication"""
486
+
487
+ @abstractmethod
488
+ def publish(self, event_type: str, data: Any) -> None:
489
+ """Publish an event"""
490
+ pass
491
+
492
+ @abstractmethod
493
+ def subscribe(self, event_type: str, handler: callable) -> str:
494
+ """Subscribe to events"""
495
+ pass
496
+
497
+ @abstractmethod
498
+ def unsubscribe(self, subscription_id: str) -> None:
499
+ """Unsubscribe from events"""
500
+ pass
501
+
502
+ @abstractmethod
503
+ async def publish_async(self, event_type: str, data: Any) -> None:
504
+ """Publish an event asynchronously"""
505
+ pass
506
+
507
+
508
+ # Interface registry for dependency injection discovery
509
+ class InterfaceRegistry:
510
+ """Registry of all core interfaces for dependency injection"""
511
+
512
+ _interfaces = {
513
+ 'service_container': IServiceContainer,
514
+ 'configuration_manager': IConfigurationManager,
515
+ 'health_monitor': IHealthMonitor,
516
+ 'agent_registry': IAgentRegistry,
517
+ 'prompt_cache': IPromptCache,
518
+ 'template_manager': ITemplateManager,
519
+ 'structured_logger': IStructuredLogger,
520
+ 'service_lifecycle': IServiceLifecycle,
521
+ 'error_handler': IErrorHandler,
522
+ 'performance_monitor': IPerformanceMonitor,
523
+ 'event_bus': IEventBus,
524
+ }
525
+
526
+ @classmethod
527
+ def get_interface(cls, name: str) -> Optional[type]:
528
+ """Get interface by name"""
529
+ return cls._interfaces.get(name)
530
+
531
+ @classmethod
532
+ def get_all_interfaces(cls) -> Dict[str, type]:
533
+ """Get all registered interfaces"""
534
+ return cls._interfaces.copy()
535
+
536
+ @classmethod
537
+ def register_interface(cls, name: str, interface: type) -> None:
538
+ """Register a new interface"""
539
+ cls._interfaces[name] = interface