kailash 0.3.2__py3-none-any.whl → 0.4.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.
- kailash/__init__.py +33 -1
- kailash/access_control/__init__.py +129 -0
- kailash/access_control/managers.py +461 -0
- kailash/access_control/rule_evaluators.py +467 -0
- kailash/access_control_abac.py +825 -0
- kailash/config/__init__.py +27 -0
- kailash/config/database_config.py +359 -0
- kailash/database/__init__.py +28 -0
- kailash/database/execution_pipeline.py +499 -0
- kailash/middleware/__init__.py +306 -0
- kailash/middleware/auth/__init__.py +33 -0
- kailash/middleware/auth/access_control.py +436 -0
- kailash/middleware/auth/auth_manager.py +422 -0
- kailash/middleware/auth/jwt_auth.py +477 -0
- kailash/middleware/auth/kailash_jwt_auth.py +616 -0
- kailash/middleware/communication/__init__.py +37 -0
- kailash/middleware/communication/ai_chat.py +989 -0
- kailash/middleware/communication/api_gateway.py +802 -0
- kailash/middleware/communication/events.py +470 -0
- kailash/middleware/communication/realtime.py +710 -0
- kailash/middleware/core/__init__.py +21 -0
- kailash/middleware/core/agent_ui.py +890 -0
- kailash/middleware/core/schema.py +643 -0
- kailash/middleware/core/workflows.py +396 -0
- kailash/middleware/database/__init__.py +63 -0
- kailash/middleware/database/base.py +113 -0
- kailash/middleware/database/base_models.py +525 -0
- kailash/middleware/database/enums.py +106 -0
- kailash/middleware/database/migrations.py +12 -0
- kailash/{api/database.py → middleware/database/models.py} +183 -291
- kailash/middleware/database/repositories.py +685 -0
- kailash/middleware/database/session_manager.py +19 -0
- kailash/middleware/mcp/__init__.py +38 -0
- kailash/middleware/mcp/client_integration.py +585 -0
- kailash/middleware/mcp/enhanced_server.py +576 -0
- kailash/nodes/__init__.py +25 -3
- kailash/nodes/admin/__init__.py +35 -0
- kailash/nodes/admin/audit_log.py +794 -0
- kailash/nodes/admin/permission_check.py +864 -0
- kailash/nodes/admin/role_management.py +823 -0
- kailash/nodes/admin/security_event.py +1519 -0
- kailash/nodes/admin/user_management.py +944 -0
- kailash/nodes/ai/a2a.py +24 -7
- kailash/nodes/ai/ai_providers.py +1 -0
- kailash/nodes/ai/embedding_generator.py +11 -11
- kailash/nodes/ai/intelligent_agent_orchestrator.py +99 -11
- kailash/nodes/ai/llm_agent.py +407 -2
- kailash/nodes/ai/self_organizing.py +85 -10
- kailash/nodes/api/auth.py +287 -6
- kailash/nodes/api/rest.py +151 -0
- kailash/nodes/auth/__init__.py +17 -0
- kailash/nodes/auth/directory_integration.py +1228 -0
- kailash/nodes/auth/enterprise_auth_provider.py +1328 -0
- kailash/nodes/auth/mfa.py +2338 -0
- kailash/nodes/auth/risk_assessment.py +872 -0
- kailash/nodes/auth/session_management.py +1093 -0
- kailash/nodes/auth/sso.py +1040 -0
- kailash/nodes/base.py +344 -13
- kailash/nodes/base_cycle_aware.py +4 -2
- kailash/nodes/base_with_acl.py +1 -1
- kailash/nodes/code/python.py +283 -10
- kailash/nodes/compliance/__init__.py +9 -0
- kailash/nodes/compliance/data_retention.py +1888 -0
- kailash/nodes/compliance/gdpr.py +2004 -0
- kailash/nodes/data/__init__.py +22 -2
- kailash/nodes/data/async_connection.py +469 -0
- kailash/nodes/data/async_sql.py +757 -0
- kailash/nodes/data/async_vector.py +598 -0
- kailash/nodes/data/readers.py +767 -0
- kailash/nodes/data/retrieval.py +360 -1
- kailash/nodes/data/sharepoint_graph.py +397 -21
- kailash/nodes/data/sql.py +94 -5
- kailash/nodes/data/streaming.py +68 -8
- kailash/nodes/data/vector_db.py +54 -4
- kailash/nodes/enterprise/__init__.py +13 -0
- kailash/nodes/enterprise/batch_processor.py +741 -0
- kailash/nodes/enterprise/data_lineage.py +497 -0
- kailash/nodes/logic/convergence.py +31 -9
- kailash/nodes/logic/operations.py +14 -3
- kailash/nodes/mixins/__init__.py +8 -0
- kailash/nodes/mixins/event_emitter.py +201 -0
- kailash/nodes/mixins/mcp.py +9 -4
- kailash/nodes/mixins/security.py +165 -0
- kailash/nodes/monitoring/__init__.py +7 -0
- kailash/nodes/monitoring/performance_benchmark.py +2497 -0
- kailash/nodes/rag/__init__.py +284 -0
- kailash/nodes/rag/advanced.py +1615 -0
- kailash/nodes/rag/agentic.py +773 -0
- kailash/nodes/rag/conversational.py +999 -0
- kailash/nodes/rag/evaluation.py +875 -0
- kailash/nodes/rag/federated.py +1188 -0
- kailash/nodes/rag/graph.py +721 -0
- kailash/nodes/rag/multimodal.py +671 -0
- kailash/nodes/rag/optimized.py +933 -0
- kailash/nodes/rag/privacy.py +1059 -0
- kailash/nodes/rag/query_processing.py +1335 -0
- kailash/nodes/rag/realtime.py +764 -0
- kailash/nodes/rag/registry.py +547 -0
- kailash/nodes/rag/router.py +837 -0
- kailash/nodes/rag/similarity.py +1854 -0
- kailash/nodes/rag/strategies.py +566 -0
- kailash/nodes/rag/workflows.py +575 -0
- kailash/nodes/security/__init__.py +19 -0
- kailash/nodes/security/abac_evaluator.py +1411 -0
- kailash/nodes/security/audit_log.py +91 -0
- kailash/nodes/security/behavior_analysis.py +1893 -0
- kailash/nodes/security/credential_manager.py +401 -0
- kailash/nodes/security/rotating_credentials.py +760 -0
- kailash/nodes/security/security_event.py +132 -0
- kailash/nodes/security/threat_detection.py +1103 -0
- kailash/nodes/testing/__init__.py +9 -0
- kailash/nodes/testing/credential_testing.py +499 -0
- kailash/nodes/transform/__init__.py +10 -2
- kailash/nodes/transform/chunkers.py +592 -1
- kailash/nodes/transform/processors.py +484 -14
- kailash/nodes/validation.py +321 -0
- kailash/runtime/access_controlled.py +1 -1
- kailash/runtime/async_local.py +41 -7
- kailash/runtime/docker.py +1 -1
- kailash/runtime/local.py +474 -55
- kailash/runtime/parallel.py +1 -1
- kailash/runtime/parallel_cyclic.py +1 -1
- kailash/runtime/testing.py +210 -2
- kailash/utils/migrations/__init__.py +25 -0
- kailash/utils/migrations/generator.py +433 -0
- kailash/utils/migrations/models.py +231 -0
- kailash/utils/migrations/runner.py +489 -0
- kailash/utils/secure_logging.py +342 -0
- kailash/workflow/__init__.py +16 -0
- kailash/workflow/cyclic_runner.py +3 -4
- kailash/workflow/graph.py +70 -2
- kailash/workflow/resilience.py +249 -0
- kailash/workflow/templates.py +726 -0
- {kailash-0.3.2.dist-info → kailash-0.4.0.dist-info}/METADATA +253 -20
- kailash-0.4.0.dist-info/RECORD +223 -0
- kailash/api/__init__.py +0 -17
- kailash/api/__main__.py +0 -6
- kailash/api/studio_secure.py +0 -893
- kailash/mcp/__main__.py +0 -13
- kailash/mcp/server_new.py +0 -336
- kailash/mcp/servers/__init__.py +0 -12
- kailash-0.3.2.dist-info/RECORD +0 -136
- {kailash-0.3.2.dist-info → kailash-0.4.0.dist-info}/WHEEL +0 -0
- {kailash-0.3.2.dist-info → kailash-0.4.0.dist-info}/entry_points.txt +0 -0
- {kailash-0.3.2.dist-info → kailash-0.4.0.dist-info}/licenses/LICENSE +0 -0
- {kailash-0.3.2.dist-info → kailash-0.4.0.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
|