kailash 0.3.2__py3-none-any.whl → 0.4.1__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 (151) hide show
  1. kailash/__init__.py +33 -1
  2. kailash/access_control/__init__.py +129 -0
  3. kailash/access_control/managers.py +461 -0
  4. kailash/access_control/rule_evaluators.py +467 -0
  5. kailash/access_control_abac.py +825 -0
  6. kailash/config/__init__.py +27 -0
  7. kailash/config/database_config.py +359 -0
  8. kailash/database/__init__.py +28 -0
  9. kailash/database/execution_pipeline.py +499 -0
  10. kailash/middleware/__init__.py +306 -0
  11. kailash/middleware/auth/__init__.py +33 -0
  12. kailash/middleware/auth/access_control.py +436 -0
  13. kailash/middleware/auth/auth_manager.py +422 -0
  14. kailash/middleware/auth/jwt_auth.py +477 -0
  15. kailash/middleware/auth/kailash_jwt_auth.py +616 -0
  16. kailash/middleware/communication/__init__.py +37 -0
  17. kailash/middleware/communication/ai_chat.py +989 -0
  18. kailash/middleware/communication/api_gateway.py +802 -0
  19. kailash/middleware/communication/events.py +470 -0
  20. kailash/middleware/communication/realtime.py +710 -0
  21. kailash/middleware/core/__init__.py +21 -0
  22. kailash/middleware/core/agent_ui.py +890 -0
  23. kailash/middleware/core/schema.py +643 -0
  24. kailash/middleware/core/workflows.py +396 -0
  25. kailash/middleware/database/__init__.py +63 -0
  26. kailash/middleware/database/base.py +113 -0
  27. kailash/middleware/database/base_models.py +525 -0
  28. kailash/middleware/database/enums.py +106 -0
  29. kailash/middleware/database/migrations.py +12 -0
  30. kailash/{api/database.py → middleware/database/models.py} +183 -291
  31. kailash/middleware/database/repositories.py +685 -0
  32. kailash/middleware/database/session_manager.py +19 -0
  33. kailash/middleware/mcp/__init__.py +38 -0
  34. kailash/middleware/mcp/client_integration.py +585 -0
  35. kailash/middleware/mcp/enhanced_server.py +576 -0
  36. kailash/nodes/__init__.py +27 -3
  37. kailash/nodes/admin/__init__.py +42 -0
  38. kailash/nodes/admin/audit_log.py +794 -0
  39. kailash/nodes/admin/permission_check.py +864 -0
  40. kailash/nodes/admin/role_management.py +823 -0
  41. kailash/nodes/admin/security_event.py +1523 -0
  42. kailash/nodes/admin/user_management.py +944 -0
  43. kailash/nodes/ai/a2a.py +24 -7
  44. kailash/nodes/ai/ai_providers.py +248 -40
  45. kailash/nodes/ai/embedding_generator.py +11 -11
  46. kailash/nodes/ai/intelligent_agent_orchestrator.py +99 -11
  47. kailash/nodes/ai/llm_agent.py +436 -5
  48. kailash/nodes/ai/self_organizing.py +85 -10
  49. kailash/nodes/ai/vision_utils.py +148 -0
  50. kailash/nodes/alerts/__init__.py +26 -0
  51. kailash/nodes/alerts/base.py +234 -0
  52. kailash/nodes/alerts/discord.py +499 -0
  53. kailash/nodes/api/auth.py +287 -6
  54. kailash/nodes/api/rest.py +151 -0
  55. kailash/nodes/auth/__init__.py +17 -0
  56. kailash/nodes/auth/directory_integration.py +1228 -0
  57. kailash/nodes/auth/enterprise_auth_provider.py +1328 -0
  58. kailash/nodes/auth/mfa.py +2338 -0
  59. kailash/nodes/auth/risk_assessment.py +872 -0
  60. kailash/nodes/auth/session_management.py +1093 -0
  61. kailash/nodes/auth/sso.py +1040 -0
  62. kailash/nodes/base.py +344 -13
  63. kailash/nodes/base_cycle_aware.py +4 -2
  64. kailash/nodes/base_with_acl.py +1 -1
  65. kailash/nodes/code/python.py +283 -10
  66. kailash/nodes/compliance/__init__.py +9 -0
  67. kailash/nodes/compliance/data_retention.py +1888 -0
  68. kailash/nodes/compliance/gdpr.py +2004 -0
  69. kailash/nodes/data/__init__.py +22 -2
  70. kailash/nodes/data/async_connection.py +469 -0
  71. kailash/nodes/data/async_sql.py +757 -0
  72. kailash/nodes/data/async_vector.py +598 -0
  73. kailash/nodes/data/readers.py +767 -0
  74. kailash/nodes/data/retrieval.py +360 -1
  75. kailash/nodes/data/sharepoint_graph.py +397 -21
  76. kailash/nodes/data/sql.py +94 -5
  77. kailash/nodes/data/streaming.py +68 -8
  78. kailash/nodes/data/vector_db.py +54 -4
  79. kailash/nodes/enterprise/__init__.py +13 -0
  80. kailash/nodes/enterprise/batch_processor.py +741 -0
  81. kailash/nodes/enterprise/data_lineage.py +497 -0
  82. kailash/nodes/logic/convergence.py +31 -9
  83. kailash/nodes/logic/operations.py +14 -3
  84. kailash/nodes/mixins/__init__.py +8 -0
  85. kailash/nodes/mixins/event_emitter.py +201 -0
  86. kailash/nodes/mixins/mcp.py +9 -4
  87. kailash/nodes/mixins/security.py +165 -0
  88. kailash/nodes/monitoring/__init__.py +7 -0
  89. kailash/nodes/monitoring/performance_benchmark.py +2497 -0
  90. kailash/nodes/rag/__init__.py +284 -0
  91. kailash/nodes/rag/advanced.py +1615 -0
  92. kailash/nodes/rag/agentic.py +773 -0
  93. kailash/nodes/rag/conversational.py +999 -0
  94. kailash/nodes/rag/evaluation.py +875 -0
  95. kailash/nodes/rag/federated.py +1188 -0
  96. kailash/nodes/rag/graph.py +721 -0
  97. kailash/nodes/rag/multimodal.py +671 -0
  98. kailash/nodes/rag/optimized.py +933 -0
  99. kailash/nodes/rag/privacy.py +1059 -0
  100. kailash/nodes/rag/query_processing.py +1335 -0
  101. kailash/nodes/rag/realtime.py +764 -0
  102. kailash/nodes/rag/registry.py +547 -0
  103. kailash/nodes/rag/router.py +837 -0
  104. kailash/nodes/rag/similarity.py +1854 -0
  105. kailash/nodes/rag/strategies.py +566 -0
  106. kailash/nodes/rag/workflows.py +575 -0
  107. kailash/nodes/security/__init__.py +19 -0
  108. kailash/nodes/security/abac_evaluator.py +1411 -0
  109. kailash/nodes/security/audit_log.py +103 -0
  110. kailash/nodes/security/behavior_analysis.py +1893 -0
  111. kailash/nodes/security/credential_manager.py +401 -0
  112. kailash/nodes/security/rotating_credentials.py +760 -0
  113. kailash/nodes/security/security_event.py +133 -0
  114. kailash/nodes/security/threat_detection.py +1103 -0
  115. kailash/nodes/testing/__init__.py +9 -0
  116. kailash/nodes/testing/credential_testing.py +499 -0
  117. kailash/nodes/transform/__init__.py +10 -2
  118. kailash/nodes/transform/chunkers.py +592 -1
  119. kailash/nodes/transform/processors.py +484 -14
  120. kailash/nodes/validation.py +321 -0
  121. kailash/runtime/access_controlled.py +1 -1
  122. kailash/runtime/async_local.py +41 -7
  123. kailash/runtime/docker.py +1 -1
  124. kailash/runtime/local.py +474 -55
  125. kailash/runtime/parallel.py +1 -1
  126. kailash/runtime/parallel_cyclic.py +1 -1
  127. kailash/runtime/testing.py +210 -2
  128. kailash/security.py +1 -1
  129. kailash/utils/migrations/__init__.py +25 -0
  130. kailash/utils/migrations/generator.py +433 -0
  131. kailash/utils/migrations/models.py +231 -0
  132. kailash/utils/migrations/runner.py +489 -0
  133. kailash/utils/secure_logging.py +342 -0
  134. kailash/workflow/__init__.py +16 -0
  135. kailash/workflow/cyclic_runner.py +3 -4
  136. kailash/workflow/graph.py +70 -2
  137. kailash/workflow/resilience.py +249 -0
  138. kailash/workflow/templates.py +726 -0
  139. {kailash-0.3.2.dist-info → kailash-0.4.1.dist-info}/METADATA +256 -20
  140. kailash-0.4.1.dist-info/RECORD +227 -0
  141. kailash/api/__init__.py +0 -17
  142. kailash/api/__main__.py +0 -6
  143. kailash/api/studio_secure.py +0 -893
  144. kailash/mcp/__main__.py +0 -13
  145. kailash/mcp/server_new.py +0 -336
  146. kailash/mcp/servers/__init__.py +0 -12
  147. kailash-0.3.2.dist-info/RECORD +0 -136
  148. {kailash-0.3.2.dist-info → kailash-0.4.1.dist-info}/WHEEL +0 -0
  149. {kailash-0.3.2.dist-info → kailash-0.4.1.dist-info}/entry_points.txt +0 -0
  150. {kailash-0.3.2.dist-info → kailash-0.4.1.dist-info}/licenses/LICENSE +0 -0
  151. {kailash-0.3.2.dist-info → kailash-0.4.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,231 @@
1
+ """Migration models and base classes."""
2
+
3
+ import hashlib
4
+ from abc import ABC, abstractmethod
5
+ from dataclasses import dataclass, field
6
+ from datetime import UTC, datetime
7
+ from typing import Any, Dict, List, Optional, Set
8
+
9
+
10
+ @dataclass
11
+ class MigrationHistory:
12
+ """Record of a migration execution."""
13
+
14
+ migration_id: str
15
+ applied_at: datetime
16
+ applied_by: str
17
+ execution_time: float # seconds
18
+ success: bool
19
+ error_message: Optional[str] = None
20
+ rollback_at: Optional[datetime] = None
21
+ rollback_by: Optional[str] = None
22
+
23
+
24
+ class Migration(ABC):
25
+ """Base class for database migrations.
26
+
27
+ Each migration should be a subclass implementing the forward()
28
+ and backward() methods for applying and rolling back changes.
29
+
30
+ Example:
31
+ class AddUserTable(Migration):
32
+ id = "001_add_user_table"
33
+ description = "Create user table"
34
+ dependencies = []
35
+
36
+ async def forward(self, connection):
37
+ await connection.execute('''
38
+ CREATE TABLE users (
39
+ id SERIAL PRIMARY KEY,
40
+ email VARCHAR(255) UNIQUE NOT NULL,
41
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
42
+ )
43
+ ''')
44
+
45
+ async def backward(self, connection):
46
+ await connection.execute('DROP TABLE IF EXISTS users')
47
+ """
48
+
49
+ # Required attributes to override
50
+ id: str = "" # Unique migration ID
51
+ description: str = "" # Human-readable description
52
+ dependencies: List[str] = [] # List of migration IDs this depends on
53
+
54
+ def __init__(self):
55
+ """Initialize migration."""
56
+ if not self.id:
57
+ raise ValueError("Migration must have an id")
58
+ if not self.description:
59
+ raise ValueError("Migration must have a description")
60
+
61
+ @abstractmethod
62
+ async def forward(self, connection: Any) -> None:
63
+ """Apply the migration forward.
64
+
65
+ Args:
66
+ connection: Database connection object
67
+ """
68
+ pass
69
+
70
+ @abstractmethod
71
+ async def backward(self, connection: Any) -> None:
72
+ """Roll back the migration.
73
+
74
+ Args:
75
+ connection: Database connection object
76
+ """
77
+ pass
78
+
79
+ async def validate(self, connection: Any) -> bool:
80
+ """Validate migration can be applied.
81
+
82
+ Override this to add custom validation logic.
83
+
84
+ Args:
85
+ connection: Database connection object
86
+
87
+ Returns:
88
+ True if migration can be applied
89
+ """
90
+ return True
91
+
92
+ def get_hash(self) -> str:
93
+ """Get hash of migration for integrity checking."""
94
+ content = f"{self.id}:{self.description}:{','.join(self.dependencies)}"
95
+ return hashlib.sha256(content.encode()).hexdigest()[:16]
96
+
97
+
98
+ class SchemaMigration(Migration):
99
+ """Migration for schema changes (DDL operations)."""
100
+
101
+ def __init__(self):
102
+ """Initialize schema migration."""
103
+ super().__init__()
104
+ self.operations: List[Dict[str, Any]] = []
105
+
106
+ def add_table(
107
+ self,
108
+ table_name: str,
109
+ columns: List[Dict[str, Any]],
110
+ indexes: Optional[List[Dict[str, Any]]] = None,
111
+ ):
112
+ """Add create table operation."""
113
+ self.operations.append(
114
+ {
115
+ "type": "create_table",
116
+ "table": table_name,
117
+ "columns": columns,
118
+ "indexes": indexes or [],
119
+ }
120
+ )
121
+
122
+ def drop_table(self, table_name: str):
123
+ """Add drop table operation."""
124
+ self.operations.append({"type": "drop_table", "table": table_name})
125
+
126
+ def add_column(
127
+ self,
128
+ table_name: str,
129
+ column_name: str,
130
+ column_type: str,
131
+ nullable: bool = True,
132
+ default: Any = None,
133
+ ):
134
+ """Add column operation."""
135
+ self.operations.append(
136
+ {
137
+ "type": "add_column",
138
+ "table": table_name,
139
+ "column": column_name,
140
+ "column_type": column_type,
141
+ "nullable": nullable,
142
+ "default": default,
143
+ }
144
+ )
145
+
146
+ def drop_column(self, table_name: str, column_name: str):
147
+ """Add drop column operation."""
148
+ self.operations.append(
149
+ {"type": "drop_column", "table": table_name, "column": column_name}
150
+ )
151
+
152
+ def add_index(
153
+ self, table_name: str, index_name: str, columns: List[str], unique: bool = False
154
+ ):
155
+ """Add create index operation."""
156
+ self.operations.append(
157
+ {
158
+ "type": "create_index",
159
+ "table": table_name,
160
+ "index": index_name,
161
+ "columns": columns,
162
+ "unique": unique,
163
+ }
164
+ )
165
+
166
+ def drop_index(self, table_name: str, index_name: str):
167
+ """Add drop index operation."""
168
+ self.operations.append(
169
+ {"type": "drop_index", "table": table_name, "index": index_name}
170
+ )
171
+
172
+
173
+ class DataMigration(Migration):
174
+ """Migration for data changes (DML operations)."""
175
+
176
+ def __init__(self):
177
+ """Initialize data migration."""
178
+ super().__init__()
179
+ self.batch_size: int = 1000
180
+
181
+ async def process_batch(
182
+ self, connection: Any, query: str, params: Optional[List[Any]] = None
183
+ ) -> int:
184
+ """Process data in batches.
185
+
186
+ Args:
187
+ connection: Database connection
188
+ query: Query to execute
189
+ params: Query parameters
190
+
191
+ Returns:
192
+ Number of rows affected
193
+ """
194
+ # Implementation depends on specific database
195
+ # This is a template method
196
+ raise NotImplementedError
197
+
198
+
199
+ @dataclass
200
+ class MigrationPlan:
201
+ """Execution plan for a set of migrations."""
202
+
203
+ migrations_to_apply: List[Migration] = field(default_factory=list)
204
+ migrations_to_rollback: List[Migration] = field(default_factory=list)
205
+ dependency_order: List[str] = field(default_factory=list)
206
+ estimated_time: float = 0.0 # seconds
207
+ warnings: List[str] = field(default_factory=list)
208
+
209
+ def add_warning(self, warning: str):
210
+ """Add a warning to the plan."""
211
+ self.warnings.append(warning)
212
+
213
+ def is_safe(self) -> bool:
214
+ """Check if plan is safe to execute."""
215
+ # No rollbacks without specific handling
216
+ if self.migrations_to_rollback:
217
+ return False
218
+
219
+ # Check circular dependencies
220
+ applied: Set[str] = set()
221
+ for migration_id in self.dependency_order:
222
+ migration = next(
223
+ (m for m in self.migrations_to_apply if m.id == migration_id), None
224
+ )
225
+ if migration:
226
+ for dep in migration.dependencies:
227
+ if dep not in applied and dep in self.dependency_order:
228
+ return False
229
+ applied.add(migration_id)
230
+
231
+ return True