kailash 0.1.5__tar.gz → 0.2.0__tar.gz

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 (139) hide show
  1. {kailash-0.1.5/src/kailash.egg-info → kailash-0.2.0}/PKG-INFO +256 -12
  2. {kailash-0.1.5 → kailash-0.2.0}/README.md +248 -11
  3. {kailash-0.1.5 → kailash-0.2.0}/pyproject.toml +8 -1
  4. {kailash-0.1.5 → kailash-0.2.0}/setup.py +1 -1
  5. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/__init__.py +1 -1
  6. kailash-0.2.0/src/kailash/access_control.py +740 -0
  7. kailash-0.2.0/src/kailash/api/__main__.py +6 -0
  8. kailash-0.2.0/src/kailash/api/auth.py +668 -0
  9. kailash-0.2.0/src/kailash/api/custom_nodes.py +285 -0
  10. kailash-0.2.0/src/kailash/api/custom_nodes_secure.py +377 -0
  11. kailash-0.2.0/src/kailash/api/database.py +620 -0
  12. kailash-0.2.0/src/kailash/api/studio.py +915 -0
  13. kailash-0.2.0/src/kailash/api/studio_secure.py +893 -0
  14. kailash-0.2.0/src/kailash/mcp/__init__.py +53 -0
  15. kailash-0.2.0/src/kailash/mcp/__main__.py +13 -0
  16. kailash-0.2.0/src/kailash/mcp/ai_registry_server.py +712 -0
  17. kailash-0.2.0/src/kailash/mcp/client.py +447 -0
  18. kailash-0.2.0/src/kailash/mcp/client_new.py +334 -0
  19. kailash-0.2.0/src/kailash/mcp/server.py +293 -0
  20. kailash-0.2.0/src/kailash/mcp/server_new.py +336 -0
  21. kailash-0.2.0/src/kailash/mcp/servers/__init__.py +12 -0
  22. kailash-0.2.0/src/kailash/mcp/servers/ai_registry.py +289 -0
  23. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/__init__.py +4 -2
  24. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/__init__.py +2 -0
  25. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/a2a.py +714 -67
  26. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/intelligent_agent_orchestrator.py +31 -37
  27. kailash-0.2.0/src/kailash/nodes/ai/iterative_llm_agent.py +1280 -0
  28. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/llm_agent.py +324 -1
  29. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/self_organizing.py +5 -6
  30. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/base.py +15 -2
  31. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/base_async.py +45 -0
  32. kailash-0.2.0/src/kailash/nodes/base_cycle_aware.py +374 -0
  33. kailash-0.2.0/src/kailash/nodes/base_with_acl.py +338 -0
  34. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/code/python.py +135 -27
  35. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/readers.py +16 -6
  36. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/writers.py +16 -6
  37. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/logic/__init__.py +8 -0
  38. kailash-0.2.0/src/kailash/nodes/logic/convergence.py +642 -0
  39. kailash-0.2.0/src/kailash/nodes/logic/loop.py +153 -0
  40. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/logic/operations.py +187 -27
  41. kailash-0.2.0/src/kailash/nodes/mixins/__init__.py +11 -0
  42. kailash-0.2.0/src/kailash/nodes/mixins/mcp.py +228 -0
  43. kailash-0.2.0/src/kailash/nodes/mixins.py +387 -0
  44. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/runtime/__init__.py +2 -1
  45. kailash-0.2.0/src/kailash/runtime/access_controlled.py +458 -0
  46. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/runtime/local.py +106 -33
  47. kailash-0.2.0/src/kailash/runtime/parallel_cyclic.py +529 -0
  48. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/sdk_exceptions.py +90 -5
  49. kailash-0.2.0/src/kailash/security.py +845 -0
  50. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/manager.py +38 -15
  51. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/models.py +1 -1
  52. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/storage/filesystem.py +30 -2
  53. kailash-0.2.0/src/kailash/utils/__init__.py +8 -0
  54. kailash-0.2.0/src/kailash/workflow/__init__.py +33 -0
  55. kailash-0.2.0/src/kailash/workflow/convergence.py +270 -0
  56. kailash-0.2.0/src/kailash/workflow/cycle_analyzer.py +768 -0
  57. kailash-0.2.0/src/kailash/workflow/cycle_builder.py +573 -0
  58. kailash-0.2.0/src/kailash/workflow/cycle_config.py +709 -0
  59. kailash-0.2.0/src/kailash/workflow/cycle_debugger.py +760 -0
  60. kailash-0.2.0/src/kailash/workflow/cycle_exceptions.py +601 -0
  61. kailash-0.2.0/src/kailash/workflow/cycle_profiler.py +671 -0
  62. kailash-0.2.0/src/kailash/workflow/cycle_state.py +338 -0
  63. kailash-0.2.0/src/kailash/workflow/cyclic_runner.py +985 -0
  64. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/workflow/graph.py +500 -39
  65. kailash-0.2.0/src/kailash/workflow/migration.py +768 -0
  66. kailash-0.2.0/src/kailash/workflow/safety.py +365 -0
  67. kailash-0.2.0/src/kailash/workflow/templates.py +744 -0
  68. kailash-0.2.0/src/kailash/workflow/validation.py +693 -0
  69. {kailash-0.1.5 → kailash-0.2.0/src/kailash.egg-info}/PKG-INFO +256 -12
  70. {kailash-0.1.5 → kailash-0.2.0}/src/kailash.egg-info/SOURCES.txt +41 -4
  71. {kailash-0.1.5 → kailash-0.2.0}/src/kailash.egg-info/requires.txt +7 -0
  72. kailash-0.1.5/src/kailash/nodes/mcp/__init__.py +0 -11
  73. kailash-0.1.5/src/kailash/nodes/mcp/client.py +0 -554
  74. kailash-0.1.5/src/kailash/nodes/mcp/resource.py +0 -682
  75. kailash-0.1.5/src/kailash/nodes/mcp/server.py +0 -577
  76. kailash-0.1.5/src/kailash/utils/__init__.py +0 -0
  77. kailash-0.1.5/src/kailash/workflow/__init__.py +0 -15
  78. {kailash-0.1.5 → kailash-0.2.0}/LICENSE +0 -0
  79. {kailash-0.1.5 → kailash-0.2.0}/MANIFEST.in +0 -0
  80. {kailash-0.1.5 → kailash-0.2.0}/setup.cfg +0 -0
  81. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/__main__.py +0 -0
  82. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/api/__init__.py +0 -0
  83. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/api/gateway.py +0 -0
  84. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/api/mcp_integration.py +0 -0
  85. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/api/workflow_api.py +0 -0
  86. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/cli/__init__.py +0 -0
  87. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/cli/commands.py +0 -0
  88. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/manifest.py +0 -0
  89. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/agents.py +0 -0
  90. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/ai_providers.py +0 -0
  91. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/embedding_generator.py +0 -0
  92. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/ai/models.py +0 -0
  93. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/api/__init__.py +0 -0
  94. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/api/auth.py +0 -0
  95. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/api/graphql.py +0 -0
  96. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/api/http.py +0 -0
  97. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/api/rate_limiting.py +0 -0
  98. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/api/rest.py +0 -0
  99. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/code/__init__.py +0 -0
  100. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/__init__.py +0 -0
  101. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/retrieval.py +0 -0
  102. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/sharepoint_graph.py +0 -0
  103. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/sources.py +0 -0
  104. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/sql.py +0 -0
  105. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/streaming.py +0 -0
  106. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/data/vector_db.py +0 -0
  107. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/logic/async_operations.py +0 -0
  108. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/logic/workflow.py +0 -0
  109. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/transform/__init__.py +0 -0
  110. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/transform/chunkers.py +0 -0
  111. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/transform/formatters.py +0 -0
  112. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/nodes/transform/processors.py +0 -0
  113. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/runtime/async_local.py +0 -0
  114. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/runtime/docker.py +0 -0
  115. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/runtime/parallel.py +0 -0
  116. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/runtime/runner.py +0 -0
  117. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/runtime/testing.py +0 -0
  118. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/__init__.py +0 -0
  119. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/metrics_collector.py +0 -0
  120. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/storage/__init__.py +0 -0
  121. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/storage/base.py +0 -0
  122. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/tracking/storage/database.py +0 -0
  123. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/utils/export.py +0 -0
  124. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/utils/templates.py +0 -0
  125. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/visualization/__init__.py +0 -0
  126. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/visualization/api.py +0 -0
  127. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/visualization/dashboard.py +0 -0
  128. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/visualization/performance.py +0 -0
  129. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/visualization/reports.py +0 -0
  130. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/workflow/builder.py +0 -0
  131. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/workflow/mermaid_visualizer.py +0 -0
  132. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/workflow/mock_registry.py +0 -0
  133. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/workflow/runner.py +0 -0
  134. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/workflow/state.py +0 -0
  135. {kailash-0.1.5 → kailash-0.2.0}/src/kailash/workflow/visualization.py +0 -0
  136. {kailash-0.1.5 → kailash-0.2.0}/src/kailash.egg-info/dependency_links.txt +0 -0
  137. {kailash-0.1.5 → kailash-0.2.0}/src/kailash.egg-info/entry_points.txt +0 -0
  138. {kailash-0.1.5 → kailash-0.2.0}/src/kailash.egg-info/not-zip-safe +0 -0
  139. {kailash-0.1.5 → kailash-0.2.0}/src/kailash.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kailash
3
- Version: 0.1.5
3
+ Version: 0.2.0
4
4
  Summary: Python SDK for the Kailash container-node architecture
5
5
  Home-page: https://github.com/integrum/kailash-python-sdk
6
6
  Author: Integrum
@@ -47,6 +47,13 @@ Requires-Dist: pytest-asyncio>=1.0.0
47
47
  Requires-Dist: pre-commit>=4.2.0
48
48
  Requires-Dist: twine>=6.1.0
49
49
  Requires-Dist: ollama>=0.5.1
50
+ Requires-Dist: sqlalchemy>=2.0.0
51
+ Requires-Dist: websockets>=12.0
52
+ Requires-Dist: httpx>=0.25.0
53
+ Requires-Dist: python-jose>=3.5.0
54
+ Requires-Dist: pytest-xdist>=3.6.0
55
+ Requires-Dist: pytest-timeout>=2.3.0
56
+ Requires-Dist: pytest-split>=0.9.0
50
57
  Provides-Extra: dev
51
58
  Requires-Dist: pytest>=7.0; extra == "dev"
52
59
  Requires-Dist: pytest-cov>=3.0; extra == "dev"
@@ -66,7 +73,7 @@ Dynamic: requires-python
66
73
  <a href="https://pepy.tech/project/kailash"><img src="https://static.pepy.tech/badge/kailash" alt="Downloads"></a>
67
74
  <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License">
68
75
  <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black">
69
- <img src="https://img.shields.io/badge/tests-753%20passing-brightgreen.svg" alt="Tests: 753 passing">
76
+ <img src="https://img.shields.io/badge/tests-734%20passing-brightgreen.svg" alt="Tests: 734 passing">
70
77
  <img src="https://img.shields.io/badge/coverage-100%25-brightgreen.svg" alt="Coverage: 100%">
71
78
  </p>
72
79
 
@@ -94,6 +101,11 @@ Dynamic: requires-python
94
101
  - 🚪 **Multi-Workflow Gateway**: Manage multiple workflows through unified API with MCP integration
95
102
  - 🤖 **Self-Organizing Agents**: Autonomous agent pools with intelligent team formation and convergence detection
96
103
  - 🧠 **Agent-to-Agent Communication**: Shared memory pools and intelligent caching for coordinated multi-agent systems
104
+ - 🔒 **Production Security**: Comprehensive security framework with path traversal prevention, code sandboxing, and audit logging
105
+ - 🎨 **Visual Workflow Builder**: Kailash Workflow Studio - drag-and-drop interface for creating and managing workflows (coming soon)
106
+ - 🔁 **Cyclic Workflows (v0.2.0)**: Universal Hybrid Cyclic Graph Architecture with 30,000+ iterations/second performance
107
+ - 🛠️ **Developer Tools**: CycleAnalyzer, CycleDebugger, CycleProfiler for production-ready cyclic workflows
108
+ - 📈 **High Performance**: Optimized execution engine supporting 100,000+ iteration workflows
97
109
 
98
110
  ## 🎯 Who Is This For?
99
111
 
@@ -278,6 +290,141 @@ results, run_id = runtime.execute(workflow)
278
290
  print("RAG Response:", results["llm_agent"]["response"])
279
291
  ```
280
292
 
293
+ ### Cyclic Workflows - Iterative Processing with Convergence
294
+
295
+ Build workflows that iterate until a condition is met, perfect for optimization, retries, and ML training:
296
+
297
+ ```python
298
+ from kailash.workflow import Workflow
299
+ from kailash.nodes.base_cycle_aware import CycleAwareNode
300
+ from kailash.nodes.base import NodeParameter
301
+ from kailash.runtime.local import LocalRuntime
302
+ from typing import Any, Dict
303
+
304
+ # Create a custom cycle-aware node for data quality improvement
305
+ class DataQualityImproverNode(CycleAwareNode):
306
+ def get_parameters(self) -> Dict[str, NodeParameter]:
307
+ return {
308
+ "data": NodeParameter(name="data", type=list, required=True),
309
+ "target_quality": NodeParameter(name="target_quality", type=float, required=False, default=0.95)
310
+ }
311
+
312
+ def run(self, context: Dict[str, Any], **kwargs) -> Dict[str, Any]:
313
+ """Iteratively improve data quality."""
314
+ data = kwargs["data"]
315
+ target_quality = kwargs.get("target_quality", 0.95)
316
+
317
+ # Get current iteration and previous state
318
+ iteration = self.get_iteration(context)
319
+ prev_state = self.get_previous_state(context)
320
+
321
+ # Calculate current quality
322
+ quality = prev_state.get("quality", 0.5) + 0.1 # Improve by 10% each iteration
323
+ quality = min(quality, 1.0)
324
+
325
+ # Process data (simplified)
326
+ processed_data = [item for item in data if item is not None]
327
+
328
+ # Track quality history
329
+ quality_history = self.accumulate_values(context, "quality_history", quality, max_history=10)
330
+
331
+ # Detect convergence trend
332
+ trend = self.detect_convergence_trend(context, "quality_history", window_size=5)
333
+ converged = quality >= target_quality or (trend and trend["slope"] < 0.01)
334
+
335
+ # Log progress
336
+ self.log_cycle_info(context, f"Iteration {iteration}: Quality={quality:.2%}")
337
+
338
+ # Save state for next iteration
339
+ self.set_cycle_state({"quality": quality, "processed_count": len(processed_data)})
340
+
341
+ return {
342
+ "data": processed_data,
343
+ "quality": quality,
344
+ "converged": converged,
345
+ "iteration": iteration,
346
+ "history": quality_history
347
+ }
348
+
349
+ # Build cyclic workflow
350
+ workflow = Workflow("quality_improvement", "Iterative Data Quality")
351
+ workflow.add_node("improver", DataQualityImproverNode())
352
+
353
+ # Create a cycle - node connects to itself!
354
+ workflow.connect("improver", "improver",
355
+ mapping={"data": "data"}, # Pass data to next iteration
356
+ cycle=True, # This is a cycle
357
+ max_iterations=20, # Safety limit
358
+ convergence_check="converged == True") # Stop condition
359
+
360
+ # Execute with automatic iteration management
361
+ runtime = LocalRuntime()
362
+ results, run_id = runtime.execute(workflow, parameters={
363
+ "improver": {
364
+ "data": [1, None, 3, None, 5, 6, None, 8, 9, 10],
365
+ "target_quality": 0.9
366
+ }
367
+ })
368
+
369
+ print(f"Converged after {results['improver']['iteration']} iterations")
370
+ print(f"Final quality: {results['improver']['quality']:.2%}")
371
+ print(f"Quality history: {results['improver']['history']}")
372
+ ```
373
+
374
+ ### NEW in v0.2.0: CycleBuilder API
375
+
376
+ The new CycleBuilder API provides a fluent interface for creating cyclic workflows:
377
+
378
+ ```python
379
+ # Modern approach with CycleBuilder
380
+ workflow.create_cycle("optimization_loop")
381
+ .connect("gradient", "optimizer")
382
+ .connect("optimizer", "evaluator")
383
+ .connect("evaluator", "gradient")
384
+ .max_iterations(100)
385
+ .converge_when("loss < 0.01")
386
+ .early_stop_when("gradient_norm < 1e-6")
387
+ .checkpoint_every(10)
388
+ .build()
389
+
390
+ # Developer tools for production workflows
391
+ from kailash.workflow import CycleAnalyzer, CycleDebugger, CycleProfiler
392
+
393
+ # Analyze cycle patterns
394
+ analyzer = CycleAnalyzer(workflow)
395
+ report = analyzer.analyze()
396
+ print(f"Found {len(report.cycles)} cycles")
397
+ print(f"Max depth: {report.max_cycle_depth}")
398
+
399
+ # Debug with breakpoints
400
+ debugger = CycleDebugger(workflow)
401
+ debugger.set_breakpoint("optimizer", iteration=50)
402
+ debugger.set_trace("gradient_norm", lambda x: x < 0.001)
403
+
404
+ # Profile performance
405
+ profiler = CycleProfiler(workflow)
406
+ profile_data = profiler.profile(runtime, parameters)
407
+ print(f"Bottleneck: {profile_data.bottleneck_node}")
408
+ print(f"Iterations/sec: {profile_data.iterations_per_second}")
409
+ ```
410
+
411
+ #### Cyclic Workflow Features
412
+
413
+ - **Built-in Iteration Management**: No manual loops or recursion needed
414
+ - **State Persistence**: Maintain state across iterations with `get_previous_state()` and `set_cycle_state()`
415
+ - **Convergence Detection**: Automatic trend analysis with `detect_convergence_trend()`
416
+ - **Value Accumulation**: Track metrics over time with `accumulate_values()`
417
+ - **Safety Limits**: Max iterations prevent infinite loops
418
+ - **Performance**: Optimized execution with ~30,000 iterations/second
419
+ - **Developer Tools**: CycleAnalyzer, CycleDebugger, CycleProfiler for production workflows
420
+
421
+ Common cyclic patterns include:
422
+ - **Retry with Backoff**: ETL pipelines with automatic retry
423
+ - **Optimization Loops**: Iterative parameter tuning
424
+ - **ML Training**: Training until accuracy threshold
425
+ - **Polling**: API polling with rate limiting
426
+ - **Stream Processing**: Windowed data processing
427
+
281
428
  ### Workflow API Wrapper - Expose Workflows as REST APIs
282
429
 
283
430
  Transform any Kailash workflow into a production-ready REST API in just 3 lines of code:
@@ -1102,6 +1249,95 @@ This example demonstrates:
1102
1249
  - **Context formatting** for LLM input
1103
1250
  - **Answer generation** using Ollama's llama3.2 model
1104
1251
 
1252
+ ### 🔒 Access Control and Security
1253
+
1254
+ Kailash SDK provides comprehensive access control and security features for enterprise deployments:
1255
+
1256
+ #### Role-Based Access Control (RBAC)
1257
+ ```python
1258
+ from kailash.access_control import UserContext, PermissionRule, NodePermission
1259
+ from kailash.runtime.access_controlled import AccessControlledRuntime
1260
+
1261
+ # Define user with roles
1262
+ user = UserContext(
1263
+ user_id="analyst_001",
1264
+ tenant_id="company_abc",
1265
+ email="analyst@company.com",
1266
+ roles=["analyst", "viewer"]
1267
+ )
1268
+
1269
+ # Create secure runtime
1270
+ runtime = AccessControlledRuntime(user_context=user)
1271
+
1272
+ # Execute workflow with automatic permission checks
1273
+ results, run_id = runtime.execute(workflow, parameters={})
1274
+ ```
1275
+
1276
+ #### Multi-Tenant Isolation
1277
+ ```python
1278
+ from kailash.access_control import get_access_control_manager, PermissionEffect, WorkflowPermission
1279
+
1280
+ # Configure tenant-based access rules
1281
+ acm = get_access_control_manager()
1282
+ acm.enabled = True
1283
+
1284
+ # Tenant isolation rule
1285
+ acm.add_rule(PermissionRule(
1286
+ id="tenant_isolation",
1287
+ resource_type="workflow",
1288
+ resource_id="customer_analytics",
1289
+ permission=WorkflowPermission.EXECUTE,
1290
+ effect=PermissionEffect.ALLOW,
1291
+ tenant_id="company_abc" # Only this tenant can access
1292
+ ))
1293
+ ```
1294
+
1295
+ #### Data Masking and Field Protection
1296
+ ```python
1297
+ from kailash.nodes.base_with_acl import add_access_control
1298
+
1299
+ # Add access control to sensitive data nodes
1300
+ secure_reader = add_access_control(
1301
+ CSVReaderNode(file_path="customers.csv"),
1302
+ enable_access_control=True,
1303
+ required_permission=NodePermission.READ_OUTPUT,
1304
+ mask_output_fields=["ssn", "phone"] # Mask for non-admin users
1305
+ )
1306
+
1307
+ workflow.add_node("secure_data", secure_reader)
1308
+ ```
1309
+
1310
+ #### Permission-Based Routing
1311
+ ```python
1312
+ # Different execution paths based on user permissions
1313
+ from kailash.access_control import NodePermission
1314
+
1315
+ # Admin users get full processing
1316
+ admin_processor = PythonCodeNode.from_function(
1317
+ lambda data: {"result": process_all_data(data)},
1318
+ name="admin_processor"
1319
+ )
1320
+
1321
+ # Analyst users get limited processing
1322
+ analyst_processor = PythonCodeNode.from_function(
1323
+ lambda data: {"result": process_limited_data(data)},
1324
+ name="analyst_processor"
1325
+ )
1326
+
1327
+ # Runtime automatically routes based on user permissions
1328
+ workflow.add_node("admin_path", admin_processor)
1329
+ workflow.add_node("analyst_path", analyst_processor)
1330
+ ```
1331
+
1332
+ **Security Features:**
1333
+ - 🔐 **JWT Authentication**: Token-based authentication with refresh support
1334
+ - 👥 **Multi-Tenant Isolation**: Complete data separation between tenants
1335
+ - 🛡️ **Field-Level Security**: Mask sensitive data based on user roles
1336
+ - 📊 **Audit Logging**: Complete access attempt logging for compliance
1337
+ - 🚫 **Path Traversal Prevention**: Built-in protection against directory attacks
1338
+ - 🏗️ **Backward Compatibility**: Existing workflows work unchanged
1339
+ - ⚡ **Performance Optimized**: Minimal overhead with caching
1340
+
1105
1341
  ## 💻 CLI Commands
1106
1342
 
1107
1343
  The SDK includes a comprehensive CLI for workflow management:
@@ -1298,6 +1534,10 @@ pre-commit run pytest-check
1298
1534
  - Immutable state management
1299
1535
  - API integration with rate limiting
1300
1536
  - OAuth 2.0 authentication
1537
+ - Production security framework
1538
+ - Path traversal prevention
1539
+ - Code execution sandboxing
1540
+ - Comprehensive security testing
1301
1541
  - SharePoint Graph API integration
1302
1542
  - **Self-organizing agent pools with 13 specialized nodes**
1303
1543
  - **Agent-to-agent communication and shared memory**
@@ -1308,16 +1548,19 @@ pre-commit run pytest-check
1308
1548
  - **Performance visualization dashboards**
1309
1549
  - **Real-time monitoring dashboard with WebSocket streaming**
1310
1550
  - **Comprehensive performance reports (HTML, Markdown, JSON)**
1311
- - **89% test coverage (571 tests)**
1312
- - **15 test categories all passing**
1313
- - 37 working examples
1551
+ - **100% test coverage (591 tests)**
1552
+ - **All test categories passing**
1553
+ - 68 working examples
1314
1554
 
1315
1555
  </td>
1316
1556
  <td width="30%">
1317
1557
 
1318
1558
  ### 🚧 In Progress
1319
- - Comprehensive API documentation
1320
- - Security audit & hardening
1559
+ - **Kailash Workflow Studio** - Visual workflow builder UI
1560
+ - React-based drag-and-drop interface
1561
+ - Multi-tenant architecture with Docker
1562
+ - WorkflowStudioAPI backend
1563
+ - Real-time execution monitoring
1321
1564
  - Performance optimizations
1322
1565
  - Docker runtime finalization
1323
1566
 
@@ -1335,11 +1578,12 @@ pre-commit run pytest-check
1335
1578
  </table>
1336
1579
 
1337
1580
  ### 🎯 Test Suite Status
1338
- - **Total Tests**: 571 passing (89%)
1339
- - **Test Categories**: 15/15 at 100%
1340
- - **Integration Tests**: 65 passing
1341
- - **Examples**: 37/37 working
1342
- - **Code Coverage**: 89%
1581
+ - **Total Tests**: 591 passing (100%)
1582
+ - **Test Categories**: All passing
1583
+ - **Integration Tests**: All passing
1584
+ - **Security Tests**: 10 consolidated comprehensive tests
1585
+ - **Examples**: 68/68 working
1586
+ - **Code Coverage**: 100%
1343
1587
 
1344
1588
  ## ⚠️ Known Issues
1345
1589
 
@@ -6,7 +6,7 @@
6
6
  <a href="https://pepy.tech/project/kailash"><img src="https://static.pepy.tech/badge/kailash" alt="Downloads"></a>
7
7
  <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="MIT License">
8
8
  <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black">
9
- <img src="https://img.shields.io/badge/tests-753%20passing-brightgreen.svg" alt="Tests: 753 passing">
9
+ <img src="https://img.shields.io/badge/tests-734%20passing-brightgreen.svg" alt="Tests: 734 passing">
10
10
  <img src="https://img.shields.io/badge/coverage-100%25-brightgreen.svg" alt="Coverage: 100%">
11
11
  </p>
12
12
 
@@ -34,6 +34,11 @@
34
34
  - 🚪 **Multi-Workflow Gateway**: Manage multiple workflows through unified API with MCP integration
35
35
  - 🤖 **Self-Organizing Agents**: Autonomous agent pools with intelligent team formation and convergence detection
36
36
  - 🧠 **Agent-to-Agent Communication**: Shared memory pools and intelligent caching for coordinated multi-agent systems
37
+ - 🔒 **Production Security**: Comprehensive security framework with path traversal prevention, code sandboxing, and audit logging
38
+ - 🎨 **Visual Workflow Builder**: Kailash Workflow Studio - drag-and-drop interface for creating and managing workflows (coming soon)
39
+ - 🔁 **Cyclic Workflows (v0.2.0)**: Universal Hybrid Cyclic Graph Architecture with 30,000+ iterations/second performance
40
+ - 🛠️ **Developer Tools**: CycleAnalyzer, CycleDebugger, CycleProfiler for production-ready cyclic workflows
41
+ - 📈 **High Performance**: Optimized execution engine supporting 100,000+ iteration workflows
37
42
 
38
43
  ## 🎯 Who Is This For?
39
44
 
@@ -218,6 +223,141 @@ results, run_id = runtime.execute(workflow)
218
223
  print("RAG Response:", results["llm_agent"]["response"])
219
224
  ```
220
225
 
226
+ ### Cyclic Workflows - Iterative Processing with Convergence
227
+
228
+ Build workflows that iterate until a condition is met, perfect for optimization, retries, and ML training:
229
+
230
+ ```python
231
+ from kailash.workflow import Workflow
232
+ from kailash.nodes.base_cycle_aware import CycleAwareNode
233
+ from kailash.nodes.base import NodeParameter
234
+ from kailash.runtime.local import LocalRuntime
235
+ from typing import Any, Dict
236
+
237
+ # Create a custom cycle-aware node for data quality improvement
238
+ class DataQualityImproverNode(CycleAwareNode):
239
+ def get_parameters(self) -> Dict[str, NodeParameter]:
240
+ return {
241
+ "data": NodeParameter(name="data", type=list, required=True),
242
+ "target_quality": NodeParameter(name="target_quality", type=float, required=False, default=0.95)
243
+ }
244
+
245
+ def run(self, context: Dict[str, Any], **kwargs) -> Dict[str, Any]:
246
+ """Iteratively improve data quality."""
247
+ data = kwargs["data"]
248
+ target_quality = kwargs.get("target_quality", 0.95)
249
+
250
+ # Get current iteration and previous state
251
+ iteration = self.get_iteration(context)
252
+ prev_state = self.get_previous_state(context)
253
+
254
+ # Calculate current quality
255
+ quality = prev_state.get("quality", 0.5) + 0.1 # Improve by 10% each iteration
256
+ quality = min(quality, 1.0)
257
+
258
+ # Process data (simplified)
259
+ processed_data = [item for item in data if item is not None]
260
+
261
+ # Track quality history
262
+ quality_history = self.accumulate_values(context, "quality_history", quality, max_history=10)
263
+
264
+ # Detect convergence trend
265
+ trend = self.detect_convergence_trend(context, "quality_history", window_size=5)
266
+ converged = quality >= target_quality or (trend and trend["slope"] < 0.01)
267
+
268
+ # Log progress
269
+ self.log_cycle_info(context, f"Iteration {iteration}: Quality={quality:.2%}")
270
+
271
+ # Save state for next iteration
272
+ self.set_cycle_state({"quality": quality, "processed_count": len(processed_data)})
273
+
274
+ return {
275
+ "data": processed_data,
276
+ "quality": quality,
277
+ "converged": converged,
278
+ "iteration": iteration,
279
+ "history": quality_history
280
+ }
281
+
282
+ # Build cyclic workflow
283
+ workflow = Workflow("quality_improvement", "Iterative Data Quality")
284
+ workflow.add_node("improver", DataQualityImproverNode())
285
+
286
+ # Create a cycle - node connects to itself!
287
+ workflow.connect("improver", "improver",
288
+ mapping={"data": "data"}, # Pass data to next iteration
289
+ cycle=True, # This is a cycle
290
+ max_iterations=20, # Safety limit
291
+ convergence_check="converged == True") # Stop condition
292
+
293
+ # Execute with automatic iteration management
294
+ runtime = LocalRuntime()
295
+ results, run_id = runtime.execute(workflow, parameters={
296
+ "improver": {
297
+ "data": [1, None, 3, None, 5, 6, None, 8, 9, 10],
298
+ "target_quality": 0.9
299
+ }
300
+ })
301
+
302
+ print(f"Converged after {results['improver']['iteration']} iterations")
303
+ print(f"Final quality: {results['improver']['quality']:.2%}")
304
+ print(f"Quality history: {results['improver']['history']}")
305
+ ```
306
+
307
+ ### NEW in v0.2.0: CycleBuilder API
308
+
309
+ The new CycleBuilder API provides a fluent interface for creating cyclic workflows:
310
+
311
+ ```python
312
+ # Modern approach with CycleBuilder
313
+ workflow.create_cycle("optimization_loop")
314
+ .connect("gradient", "optimizer")
315
+ .connect("optimizer", "evaluator")
316
+ .connect("evaluator", "gradient")
317
+ .max_iterations(100)
318
+ .converge_when("loss < 0.01")
319
+ .early_stop_when("gradient_norm < 1e-6")
320
+ .checkpoint_every(10)
321
+ .build()
322
+
323
+ # Developer tools for production workflows
324
+ from kailash.workflow import CycleAnalyzer, CycleDebugger, CycleProfiler
325
+
326
+ # Analyze cycle patterns
327
+ analyzer = CycleAnalyzer(workflow)
328
+ report = analyzer.analyze()
329
+ print(f"Found {len(report.cycles)} cycles")
330
+ print(f"Max depth: {report.max_cycle_depth}")
331
+
332
+ # Debug with breakpoints
333
+ debugger = CycleDebugger(workflow)
334
+ debugger.set_breakpoint("optimizer", iteration=50)
335
+ debugger.set_trace("gradient_norm", lambda x: x < 0.001)
336
+
337
+ # Profile performance
338
+ profiler = CycleProfiler(workflow)
339
+ profile_data = profiler.profile(runtime, parameters)
340
+ print(f"Bottleneck: {profile_data.bottleneck_node}")
341
+ print(f"Iterations/sec: {profile_data.iterations_per_second}")
342
+ ```
343
+
344
+ #### Cyclic Workflow Features
345
+
346
+ - **Built-in Iteration Management**: No manual loops or recursion needed
347
+ - **State Persistence**: Maintain state across iterations with `get_previous_state()` and `set_cycle_state()`
348
+ - **Convergence Detection**: Automatic trend analysis with `detect_convergence_trend()`
349
+ - **Value Accumulation**: Track metrics over time with `accumulate_values()`
350
+ - **Safety Limits**: Max iterations prevent infinite loops
351
+ - **Performance**: Optimized execution with ~30,000 iterations/second
352
+ - **Developer Tools**: CycleAnalyzer, CycleDebugger, CycleProfiler for production workflows
353
+
354
+ Common cyclic patterns include:
355
+ - **Retry with Backoff**: ETL pipelines with automatic retry
356
+ - **Optimization Loops**: Iterative parameter tuning
357
+ - **ML Training**: Training until accuracy threshold
358
+ - **Polling**: API polling with rate limiting
359
+ - **Stream Processing**: Windowed data processing
360
+
221
361
  ### Workflow API Wrapper - Expose Workflows as REST APIs
222
362
 
223
363
  Transform any Kailash workflow into a production-ready REST API in just 3 lines of code:
@@ -1042,6 +1182,95 @@ This example demonstrates:
1042
1182
  - **Context formatting** for LLM input
1043
1183
  - **Answer generation** using Ollama's llama3.2 model
1044
1184
 
1185
+ ### 🔒 Access Control and Security
1186
+
1187
+ Kailash SDK provides comprehensive access control and security features for enterprise deployments:
1188
+
1189
+ #### Role-Based Access Control (RBAC)
1190
+ ```python
1191
+ from kailash.access_control import UserContext, PermissionRule, NodePermission
1192
+ from kailash.runtime.access_controlled import AccessControlledRuntime
1193
+
1194
+ # Define user with roles
1195
+ user = UserContext(
1196
+ user_id="analyst_001",
1197
+ tenant_id="company_abc",
1198
+ email="analyst@company.com",
1199
+ roles=["analyst", "viewer"]
1200
+ )
1201
+
1202
+ # Create secure runtime
1203
+ runtime = AccessControlledRuntime(user_context=user)
1204
+
1205
+ # Execute workflow with automatic permission checks
1206
+ results, run_id = runtime.execute(workflow, parameters={})
1207
+ ```
1208
+
1209
+ #### Multi-Tenant Isolation
1210
+ ```python
1211
+ from kailash.access_control import get_access_control_manager, PermissionEffect, WorkflowPermission
1212
+
1213
+ # Configure tenant-based access rules
1214
+ acm = get_access_control_manager()
1215
+ acm.enabled = True
1216
+
1217
+ # Tenant isolation rule
1218
+ acm.add_rule(PermissionRule(
1219
+ id="tenant_isolation",
1220
+ resource_type="workflow",
1221
+ resource_id="customer_analytics",
1222
+ permission=WorkflowPermission.EXECUTE,
1223
+ effect=PermissionEffect.ALLOW,
1224
+ tenant_id="company_abc" # Only this tenant can access
1225
+ ))
1226
+ ```
1227
+
1228
+ #### Data Masking and Field Protection
1229
+ ```python
1230
+ from kailash.nodes.base_with_acl import add_access_control
1231
+
1232
+ # Add access control to sensitive data nodes
1233
+ secure_reader = add_access_control(
1234
+ CSVReaderNode(file_path="customers.csv"),
1235
+ enable_access_control=True,
1236
+ required_permission=NodePermission.READ_OUTPUT,
1237
+ mask_output_fields=["ssn", "phone"] # Mask for non-admin users
1238
+ )
1239
+
1240
+ workflow.add_node("secure_data", secure_reader)
1241
+ ```
1242
+
1243
+ #### Permission-Based Routing
1244
+ ```python
1245
+ # Different execution paths based on user permissions
1246
+ from kailash.access_control import NodePermission
1247
+
1248
+ # Admin users get full processing
1249
+ admin_processor = PythonCodeNode.from_function(
1250
+ lambda data: {"result": process_all_data(data)},
1251
+ name="admin_processor"
1252
+ )
1253
+
1254
+ # Analyst users get limited processing
1255
+ analyst_processor = PythonCodeNode.from_function(
1256
+ lambda data: {"result": process_limited_data(data)},
1257
+ name="analyst_processor"
1258
+ )
1259
+
1260
+ # Runtime automatically routes based on user permissions
1261
+ workflow.add_node("admin_path", admin_processor)
1262
+ workflow.add_node("analyst_path", analyst_processor)
1263
+ ```
1264
+
1265
+ **Security Features:**
1266
+ - 🔐 **JWT Authentication**: Token-based authentication with refresh support
1267
+ - 👥 **Multi-Tenant Isolation**: Complete data separation between tenants
1268
+ - 🛡️ **Field-Level Security**: Mask sensitive data based on user roles
1269
+ - 📊 **Audit Logging**: Complete access attempt logging for compliance
1270
+ - 🚫 **Path Traversal Prevention**: Built-in protection against directory attacks
1271
+ - 🏗️ **Backward Compatibility**: Existing workflows work unchanged
1272
+ - ⚡ **Performance Optimized**: Minimal overhead with caching
1273
+
1045
1274
  ## 💻 CLI Commands
1046
1275
 
1047
1276
  The SDK includes a comprehensive CLI for workflow management:
@@ -1238,6 +1467,10 @@ pre-commit run pytest-check
1238
1467
  - Immutable state management
1239
1468
  - API integration with rate limiting
1240
1469
  - OAuth 2.0 authentication
1470
+ - Production security framework
1471
+ - Path traversal prevention
1472
+ - Code execution sandboxing
1473
+ - Comprehensive security testing
1241
1474
  - SharePoint Graph API integration
1242
1475
  - **Self-organizing agent pools with 13 specialized nodes**
1243
1476
  - **Agent-to-agent communication and shared memory**
@@ -1248,16 +1481,19 @@ pre-commit run pytest-check
1248
1481
  - **Performance visualization dashboards**
1249
1482
  - **Real-time monitoring dashboard with WebSocket streaming**
1250
1483
  - **Comprehensive performance reports (HTML, Markdown, JSON)**
1251
- - **89% test coverage (571 tests)**
1252
- - **15 test categories all passing**
1253
- - 37 working examples
1484
+ - **100% test coverage (591 tests)**
1485
+ - **All test categories passing**
1486
+ - 68 working examples
1254
1487
 
1255
1488
  </td>
1256
1489
  <td width="30%">
1257
1490
 
1258
1491
  ### 🚧 In Progress
1259
- - Comprehensive API documentation
1260
- - Security audit & hardening
1492
+ - **Kailash Workflow Studio** - Visual workflow builder UI
1493
+ - React-based drag-and-drop interface
1494
+ - Multi-tenant architecture with Docker
1495
+ - WorkflowStudioAPI backend
1496
+ - Real-time execution monitoring
1261
1497
  - Performance optimizations
1262
1498
  - Docker runtime finalization
1263
1499
 
@@ -1275,11 +1511,12 @@ pre-commit run pytest-check
1275
1511
  </table>
1276
1512
 
1277
1513
  ### 🎯 Test Suite Status
1278
- - **Total Tests**: 571 passing (89%)
1279
- - **Test Categories**: 15/15 at 100%
1280
- - **Integration Tests**: 65 passing
1281
- - **Examples**: 37/37 working
1282
- - **Code Coverage**: 89%
1514
+ - **Total Tests**: 591 passing (100%)
1515
+ - **Test Categories**: All passing
1516
+ - **Integration Tests**: All passing
1517
+ - **Security Tests**: 10 consolidated comprehensive tests
1518
+ - **Examples**: 68/68 working
1519
+ - **Code Coverage**: 100%
1283
1520
 
1284
1521
  ## ⚠️ Known Issues
1285
1522
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "kailash"
7
- version = "0.1.5"
7
+ version = "0.2.0"
8
8
  description = "Python SDK for the Kailash container-node architecture"
9
9
  authors = [
10
10
  {name = "Integrum", email = "info@integrum.com"}
@@ -51,6 +51,13 @@ dependencies = [
51
51
  "pre-commit>=4.2.0",
52
52
  "twine>=6.1.0",
53
53
  "ollama>=0.5.1",
54
+ "sqlalchemy>=2.0.0",
55
+ "websockets>=12.0",
56
+ "httpx>=0.25.0",
57
+ "python-jose>=3.5.0",
58
+ "pytest-xdist>=3.6.0",
59
+ "pytest-timeout>=2.3.0",
60
+ "pytest-split>=0.9.0",
54
61
  ]
55
62
 
56
63
  [project.optional-dependencies]
@@ -13,7 +13,7 @@ with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
13
13
  # Package configuration
14
14
  setup(
15
15
  name="kailash",
16
- version="0.1.4",
16
+ version="0.2.0",
17
17
  author="Integrum",
18
18
  author_email="info@integrum.com",
19
19
  description="Python SDK for the Kailash container-node architecture",
@@ -15,7 +15,7 @@ from kailash.workflow.visualization import WorkflowVisualizer
15
15
  # For backward compatibility
16
16
  WorkflowGraph = Workflow
17
17
 
18
- __version__ = "0.1.4"
18
+ __version__ = "0.2.0"
19
19
 
20
20
  __all__ = [
21
21
  "Workflow",