kailash 0.8.4__py3-none-any.whl → 0.8.6__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.
Files changed (99) hide show
  1. kailash/__init__.py +5 -11
  2. kailash/channels/__init__.py +2 -1
  3. kailash/channels/mcp_channel.py +23 -4
  4. kailash/cli/__init__.py +11 -1
  5. kailash/cli/validate_imports.py +202 -0
  6. kailash/cli/validation_audit.py +570 -0
  7. kailash/core/actors/supervisor.py +1 -1
  8. kailash/core/resilience/bulkhead.py +15 -5
  9. kailash/core/resilience/circuit_breaker.py +74 -1
  10. kailash/core/resilience/health_monitor.py +433 -33
  11. kailash/edge/compliance.py +33 -0
  12. kailash/edge/consistency.py +609 -0
  13. kailash/edge/coordination/__init__.py +30 -0
  14. kailash/edge/coordination/global_ordering.py +355 -0
  15. kailash/edge/coordination/leader_election.py +217 -0
  16. kailash/edge/coordination/partition_detector.py +296 -0
  17. kailash/edge/coordination/raft.py +485 -0
  18. kailash/edge/discovery.py +63 -1
  19. kailash/edge/migration/__init__.py +19 -0
  20. kailash/edge/migration/edge_migration_service.py +384 -0
  21. kailash/edge/migration/edge_migrator.py +832 -0
  22. kailash/edge/monitoring/__init__.py +21 -0
  23. kailash/edge/monitoring/edge_monitor.py +736 -0
  24. kailash/edge/prediction/__init__.py +10 -0
  25. kailash/edge/prediction/predictive_warmer.py +591 -0
  26. kailash/edge/resource/__init__.py +102 -0
  27. kailash/edge/resource/cloud_integration.py +796 -0
  28. kailash/edge/resource/cost_optimizer.py +949 -0
  29. kailash/edge/resource/docker_integration.py +919 -0
  30. kailash/edge/resource/kubernetes_integration.py +893 -0
  31. kailash/edge/resource/platform_integration.py +913 -0
  32. kailash/edge/resource/predictive_scaler.py +959 -0
  33. kailash/edge/resource/resource_analyzer.py +824 -0
  34. kailash/edge/resource/resource_pools.py +610 -0
  35. kailash/integrations/dataflow_edge.py +261 -0
  36. kailash/mcp_server/registry_integration.py +1 -1
  37. kailash/mcp_server/server.py +351 -8
  38. kailash/mcp_server/transports.py +305 -0
  39. kailash/middleware/gateway/event_store.py +1 -0
  40. kailash/monitoring/__init__.py +18 -0
  41. kailash/monitoring/alerts.py +646 -0
  42. kailash/monitoring/metrics.py +677 -0
  43. kailash/nodes/__init__.py +2 -0
  44. kailash/nodes/ai/semantic_memory.py +2 -2
  45. kailash/nodes/base.py +622 -1
  46. kailash/nodes/code/python.py +44 -3
  47. kailash/nodes/data/async_sql.py +42 -20
  48. kailash/nodes/edge/__init__.py +36 -0
  49. kailash/nodes/edge/base.py +240 -0
  50. kailash/nodes/edge/cloud_node.py +710 -0
  51. kailash/nodes/edge/coordination.py +239 -0
  52. kailash/nodes/edge/docker_node.py +825 -0
  53. kailash/nodes/edge/edge_data.py +582 -0
  54. kailash/nodes/edge/edge_migration_node.py +396 -0
  55. kailash/nodes/edge/edge_monitoring_node.py +421 -0
  56. kailash/nodes/edge/edge_state.py +673 -0
  57. kailash/nodes/edge/edge_warming_node.py +393 -0
  58. kailash/nodes/edge/kubernetes_node.py +652 -0
  59. kailash/nodes/edge/platform_node.py +766 -0
  60. kailash/nodes/edge/resource_analyzer_node.py +378 -0
  61. kailash/nodes/edge/resource_optimizer_node.py +501 -0
  62. kailash/nodes/edge/resource_scaler_node.py +397 -0
  63. kailash/nodes/governance.py +410 -0
  64. kailash/nodes/ports.py +676 -0
  65. kailash/nodes/rag/registry.py +1 -1
  66. kailash/nodes/transaction/distributed_transaction_manager.py +48 -1
  67. kailash/nodes/transaction/saga_state_storage.py +2 -1
  68. kailash/nodes/validation.py +8 -8
  69. kailash/runtime/local.py +374 -1
  70. kailash/runtime/validation/__init__.py +12 -0
  71. kailash/runtime/validation/connection_context.py +119 -0
  72. kailash/runtime/validation/enhanced_error_formatter.py +202 -0
  73. kailash/runtime/validation/error_categorizer.py +164 -0
  74. kailash/runtime/validation/import_validator.py +446 -0
  75. kailash/runtime/validation/metrics.py +380 -0
  76. kailash/runtime/validation/performance.py +615 -0
  77. kailash/runtime/validation/suggestion_engine.py +212 -0
  78. kailash/testing/fixtures.py +2 -2
  79. kailash/utils/data_paths.py +74 -0
  80. kailash/workflow/builder.py +413 -8
  81. kailash/workflow/contracts.py +418 -0
  82. kailash/workflow/edge_infrastructure.py +369 -0
  83. kailash/workflow/mermaid_visualizer.py +3 -1
  84. kailash/workflow/migration.py +3 -3
  85. kailash/workflow/templates.py +6 -6
  86. kailash/workflow/type_inference.py +669 -0
  87. kailash/workflow/validation.py +134 -3
  88. {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/METADATA +52 -34
  89. {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/RECORD +93 -42
  90. kailash/nexus/__init__.py +0 -21
  91. kailash/nexus/cli/__init__.py +0 -5
  92. kailash/nexus/cli/__main__.py +0 -6
  93. kailash/nexus/cli/main.py +0 -176
  94. kailash/nexus/factory.py +0 -413
  95. kailash/nexus/gateway.py +0 -545
  96. {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/WHEEL +0 -0
  97. {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/entry_points.txt +0 -0
  98. {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/licenses/LICENSE +0 -0
  99. {kailash-0.8.4.dist-info → kailash-0.8.6.dist-info}/top_level.txt +0 -0
kailash/__init__.py CHANGED
@@ -3,10 +3,10 @@
3
3
  The Kailash SDK provides a comprehensive framework for creating nodes and workflows
4
4
  that align with container-node architecture while allowing rapid prototyping.
5
5
 
6
- New in v0.7.0: Complete DataFlow and Nexus application frameworks, infrastructure hardening
7
- with 100% E2E test pass rate, enhanced AsyncNode event loop handling, 8 new monitoring operations,
8
- distributed transactions, QueryBuilder/QueryCache with Redis, and real MCP execution by default.
9
- Previous v0.6.6: AgentUIMiddleware shared workflow fix, execute() method standardization.
6
+ New in v0.8.6: Enhanced parameter validation system with 4 modes (off/warn/strict/debug),
7
+ ParameterDebugger for comprehensive flow tracing (10x faster debugging), production-ready
8
+ performance (<1ms overhead), and complete troubleshooting documentation.
9
+ Previous v0.8.5: Test infrastructure enhancement, application framework improvements.
10
10
  """
11
11
 
12
12
  from kailash.nodes.base import Node, NodeMetadata, NodeParameter
@@ -26,9 +26,6 @@ try:
26
26
  RealtimeMiddleware,
27
27
  )
28
28
 
29
- # Import Nexus multi-channel framework (v0.6.7+)
30
- from kailash.nexus import NexusGateway, create_nexus
31
-
32
29
  # Import new server classes (v0.6.7+)
33
30
  from kailash.servers import (
34
31
  DurableWorkflowServer,
@@ -52,7 +49,7 @@ except ImportError:
52
49
  # For backward compatibility
53
50
  WorkflowGraph = Workflow
54
51
 
55
- __version__ = "0.8.4"
52
+ __version__ = "0.8.6"
56
53
 
57
54
  __all__ = [
58
55
  # Core workflow components
@@ -86,8 +83,5 @@ if _MIDDLEWARE_AVAILABLE:
86
83
  "create_enterprise_gateway",
87
84
  "create_durable_gateway",
88
85
  "create_basic_gateway",
89
- # Nexus multi-channel framework
90
- "NexusGateway",
91
- "create_nexus",
92
86
  ]
93
87
  )
@@ -5,7 +5,7 @@ enabling unified management of API, CLI, and MCP interfaces through a common cha
5
5
  """
6
6
 
7
7
  from .api_channel import APIChannel
8
- from .base import Channel, ChannelConfig
8
+ from .base import Channel, ChannelConfig, ChannelType
9
9
  from .cli_channel import CLIChannel
10
10
  from .mcp_channel import MCPChannel
11
11
  from .session import CrossChannelSession, SessionManager
@@ -13,6 +13,7 @@ from .session import CrossChannelSession, SessionManager
13
13
  __all__ = [
14
14
  "Channel",
15
15
  "ChannelConfig",
16
+ "ChannelType",
16
17
  "APIChannel",
17
18
  "CLIChannel",
18
19
  "MCPChannel",
@@ -84,6 +84,7 @@ class MCPChannel(Channel):
84
84
  # MCP-specific state
85
85
  self._clients: Dict[str, Dict[str, Any]] = {}
86
86
  self._server_task: Optional[asyncio.Task] = None
87
+ self._mcp_server_task: Optional[asyncio.Task] = None
87
88
 
88
89
  logger.info(f"Initialized MCP channel {self.name}")
89
90
 
@@ -202,8 +203,15 @@ class MCPChannel(Channel):
202
203
  self.status = ChannelStatus.STARTING
203
204
  self._setup_event_queue()
204
205
 
205
- # Start MCP server
206
- await self.mcp_server.start()
206
+ # Start MCP server (Core SDK uses run() method, not start())
207
+ # For async operation, we need to run it in a separate task
208
+ if hasattr(self.mcp_server, "run"):
209
+ # Core SDK MCPServer uses run() method
210
+ loop = asyncio.get_event_loop()
211
+ self._mcp_server_task = loop.run_in_executor(None, self.mcp_server.run)
212
+ else:
213
+ # Fallback to start() if available
214
+ await self.mcp_server.start()
207
215
 
208
216
  # Start server task for handling connections
209
217
  self._server_task = asyncio.create_task(self._server_loop())
@@ -261,9 +269,20 @@ class MCPChannel(Channel):
261
269
  except asyncio.CancelledError:
262
270
  pass
263
271
 
272
+ # Stop MCP server task if running
273
+ if hasattr(self, "_mcp_server_task") and self._mcp_server_task:
274
+ self._mcp_server_task.cancel()
275
+ try:
276
+ await self._mcp_server_task
277
+ except asyncio.CancelledError:
278
+ pass
279
+
264
280
  # Stop MCP server
265
- if self.mcp_server:
266
- await self.mcp_server.stop()
281
+ if self.mcp_server and hasattr(self.mcp_server, "stop"):
282
+ try:
283
+ await self.mcp_server.stop()
284
+ except Exception as e:
285
+ logger.warning(f"Error stopping MCP server: {e}")
267
286
 
268
287
  await self._cleanup()
269
288
  self.status = ChannelStatus.STOPPED
kailash/cli/__init__.py CHANGED
@@ -1,5 +1,15 @@
1
1
  """Kailash SDK Command Line Interface."""
2
2
 
3
3
  from .commands import cli as main
4
+ from .validation_audit import (
5
+ ReportFormatter,
6
+ ValidationAuditReport,
7
+ WorkflowValidationAuditor,
8
+ )
4
9
 
5
- __all__ = ["main"]
10
+ __all__ = [
11
+ "main",
12
+ "WorkflowValidationAuditor",
13
+ "ValidationAuditReport",
14
+ "ReportFormatter",
15
+ ]
@@ -0,0 +1,202 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Command-line tool for validating import paths for production deployment.
4
+
5
+ Usage:
6
+ python -m kailash.cli.validate_imports [path] [options]
7
+
8
+ Examples:
9
+ # Validate current directory
10
+ python -m kailash.cli.validate_imports
11
+
12
+ # Validate specific directory
13
+ python -m kailash.cli.validate_imports src/myapp
14
+
15
+ # Fix imports (dry run)
16
+ python -m kailash.cli.validate_imports src/myapp --fix
17
+
18
+ # Fix imports (apply changes)
19
+ python -m kailash.cli.validate_imports src/myapp --fix --apply
20
+ """
21
+
22
+ import argparse
23
+ import sys
24
+ from pathlib import Path
25
+ from typing import List
26
+
27
+ from kailash.runtime.validation import ImportIssue, ImportPathValidator
28
+
29
+
30
+ def main():
31
+ """Main entry point for import validation CLI."""
32
+ parser = argparse.ArgumentParser(
33
+ description="Validate Python imports for production deployment compatibility",
34
+ formatter_class=argparse.RawDescriptionHelpFormatter,
35
+ epilog="""
36
+ Examples:
37
+ %(prog)s # Validate current directory
38
+ %(prog)s src/myapp # Validate specific directory
39
+ %(prog)s src/myapp --fix # Show import fixes (dry run)
40
+ %(prog)s --file module.py # Validate single file
41
+
42
+ For more info, see: sdk-users/7-gold-standards/absolute-imports-gold-standard.md
43
+ """,
44
+ )
45
+
46
+ parser.add_argument(
47
+ "path",
48
+ nargs="?",
49
+ default=".",
50
+ help="Path to validate (directory or file, default: current directory)",
51
+ )
52
+
53
+ parser.add_argument(
54
+ "--file",
55
+ "-f",
56
+ action="store_true",
57
+ help="Treat path as a single file instead of directory",
58
+ )
59
+
60
+ parser.add_argument(
61
+ "--fix", action="store_true", help="Show suggested fixes for import issues"
62
+ )
63
+
64
+ parser.add_argument(
65
+ "--apply",
66
+ action="store_true",
67
+ help="Apply fixes (use with --fix, CAUTION: modifies files!)",
68
+ )
69
+
70
+ parser.add_argument(
71
+ "--no-recursive", "-n", action="store_true", help="Do not scan subdirectories"
72
+ )
73
+
74
+ parser.add_argument(
75
+ "--include-tests", action="store_true", help="Include test files in validation"
76
+ )
77
+
78
+ parser.add_argument("--json", action="store_true", help="Output results as JSON")
79
+
80
+ parser.add_argument(
81
+ "--quiet",
82
+ "-q",
83
+ action="store_true",
84
+ help="Only show errors, no informational output",
85
+ )
86
+
87
+ parser.add_argument(
88
+ "--verbose", "-v", action="store_true", help="Show detailed output"
89
+ )
90
+
91
+ args = parser.parse_args()
92
+
93
+ # Create validator
94
+ validator = ImportPathValidator()
95
+
96
+ # Validate path
97
+ path = Path(args.path)
98
+ if not path.exists():
99
+ print(f"Error: Path '{path}' does not exist", file=sys.stderr)
100
+ sys.exit(1)
101
+
102
+ # Collect issues
103
+ issues: List[ImportIssue] = []
104
+
105
+ if args.file or path.is_file():
106
+ # Validate single file
107
+ if args.verbose:
108
+ print(f"Validating file: {path}")
109
+ issues = validator.validate_file(str(path))
110
+ else:
111
+ # Validate directory
112
+ if args.verbose:
113
+ print(f"Validating directory: {path}")
114
+ print(f"Recursive: {not args.no_recursive}")
115
+ print(f"Include tests: {args.include_tests}")
116
+ print()
117
+
118
+ # TODO: Add support for include_tests flag in validator
119
+ issues = validator.validate_directory(
120
+ str(path), recursive=not args.no_recursive
121
+ )
122
+
123
+ # Handle results
124
+ if args.json:
125
+ import json
126
+
127
+ # Convert issues to JSON-serializable format
128
+ issues_data = [
129
+ {
130
+ "file": issue.file_path,
131
+ "line": issue.line_number,
132
+ "import": issue.import_statement,
133
+ "type": issue.issue_type.value,
134
+ "severity": issue.severity,
135
+ "message": issue.message,
136
+ "suggestion": issue.suggestion,
137
+ }
138
+ for issue in issues
139
+ ]
140
+ print(
141
+ json.dumps(
142
+ {
143
+ "issues": issues_data,
144
+ "total": len(issues),
145
+ "critical": len([i for i in issues if i.severity == "critical"]),
146
+ "warnings": len([i for i in issues if i.severity == "warning"]),
147
+ },
148
+ indent=2,
149
+ )
150
+ )
151
+
152
+ elif args.fix:
153
+ # Show fixes
154
+ if not issues:
155
+ if not args.quiet:
156
+ print("āœ… No import issues found!")
157
+ sys.exit(0)
158
+
159
+ print(f"Found {len(issues)} import issues\n")
160
+
161
+ # Group by file
162
+ files_with_issues = {}
163
+ for issue in issues:
164
+ if issue.file_path not in files_with_issues:
165
+ files_with_issues[issue.file_path] = []
166
+ files_with_issues[issue.file_path].append(issue)
167
+
168
+ for file_path, file_issues in files_with_issues.items():
169
+ print(f"\nšŸ“„ {file_path}")
170
+ print("-" * 60)
171
+
172
+ if args.apply:
173
+ # Apply fixes
174
+ fixes = validator.fix_imports_in_file(file_path, dry_run=False)
175
+ for original, fixed in fixes:
176
+ print(f" āŒ {original}")
177
+ print(f" āœ… {fixed}")
178
+ print(f"\n Applied {len(fixes)} fixes to {file_path}")
179
+ else:
180
+ # Show proposed fixes
181
+ for issue in file_issues:
182
+ print(f" Line {issue.line_number}: {issue.import_statement}")
183
+ print(f" Issue: {issue.message}")
184
+ print(f" Fix: {issue.suggestion}")
185
+ print()
186
+
187
+ if not args.apply:
188
+ print("\nšŸ’” To apply these fixes, run with --fix --apply")
189
+ print("āš ļø CAUTION: This will modify your files!")
190
+
191
+ else:
192
+ # Standard report
193
+ report = validator.generate_report(issues)
194
+ print(report)
195
+
196
+ # Exit code based on critical issues
197
+ critical_count = len([i for i in issues if i.severity == "critical"])
198
+ sys.exit(1 if critical_count > 0 else 0)
199
+
200
+
201
+ if __name__ == "__main__":
202
+ main()