Kailash DataFlow - Zero-Config Database Framework
DataFlow is a zero-config database framework built on Kailash Core SDK that automatically generates workflow nodes from database models.
Overview
DataFlow transforms database models into workflow nodes automatically, providing:
- Automatic Node Generation: 11 nodes per model (@db.model decorator)
- Multi-Database Support: PostgreSQL, MySQL, SQLite (SQL) + MongoDB (Document) + pgvector (Vector Search)
- Enterprise Features: Multi-tenancy, multi-instance isolation, transactions
- Zero Configuration: String IDs preserved, deferred schema operations
- Integration Ready: Works with Nexus for multi-channel deployment
- Specialized Adapters: SQL (11 nodes/model), Document (8 nodes), Vector (3 nodes)
L
🛠️ Developer Experience Tools
Enhanced Error System
DataFlow provides comprehensive error enhancement across all database operations, strict mode validation for build-time error prevention, and an intelligent debug agent for automated error diagnosis.
Error Enhancement
What It Is: Automatic transformation of Python exceptions into rich, actionable error messages with context, root causes, and solutions.
All DataFlow errors include:
- Error codes: DF-XXX format (DataFlow) or KS-XXX (Core SDK)
- Context: Node, parameters, workflow state
- Root causes: Why the error occurred (3-5 possibilities with probability scores)
- Solutions: How to fix it (with code examples)
Example:
# Missing parameter error shows:
# - Error Code: DF-101
# - Missing parameter: "id"
# - 3 solutions with code examples
# - Link to documentation
workflow.add_node("UserCreateNode", "create", {
"name": "Alice" # Missing "id" - error enhanced automatically
})
Error Categories:
- DF-1XX: Parameter errors (missing, type mismatch, validation)
- DF-2XX: Connection errors (missing, circular, type mismatch)
- DF-3XX: Migration errors (schema, constraints)
- DF-4XX: Configuration errors (database URL, auth)
- DF-5XX: Runtime errors (timeouts, resources)
Architecture:
# BaseErrorEnhancer - Shared abstraction
# ├─ CoreErrorEnhancer - KS-501 to KS-508 (Core SDK)
# └─ DataFlowErrorEnhancer - DF-XXX codes (DataFlow)
Strict Mode Validation
What It Is: Build-time validation system with 4 layers to catch errors before workflow execution.
Validation Layers:
- Model Validation - Primary keys, auto-fields, reserved fields, field types
- Parameter Validation - Required parameters, types, values, CreateNode structure
- Connection Validation - Source/target nodes, type compatibility, dot notation
- Workflow Validation - Structure, circular dependencies
Configuration:
from dataflow import DataFlow
from dataflow.validation.strict_mode import StrictModeConfig
config = StrictModeConfig(
enabled=True,
validate_models=True,
validate_parameters=True,
validate_connections=True,
validate_workflows=True,
fail_fast=True, # Stop on first error
verbose=False # Minimal output
)
db = DataFlow("postgresql://...", strict_mode_config=config)
When to Use:
- ✅ Development: Catch errors early
- ✅ CI/CD: Validate workflows before deployment
- ✅ Production: Prevent invalid workflow execution
Documentation:
- HOW-TO Guide:
dataflow-strict-mode
- Architecture Guide:
dataflow-validation-layers
Debug Agent
What It Is: Intelligent error analysis system that automatically diagnoses errors and provides ranked, actionable solutions.
5-Stage Pipeline:
- Capture - Stack traces, context, error chains
- Categorize - 50+ patterns across 5 categories (PARAMETER, CONNECTION, MIGRATION, RUNTIME, CONFIGURATION)
- Analyze - Inspector integration for workflow analysis
- Suggest - 60+ solution templates with relevance scoring
- Format - CLI (color-coded), JSON (machine-readable), dict (programmatic)
Usage:
from dataflow.debug.debug_agent import DebugAgent
from dataflow.debug.knowledge_base import KnowledgeBase
from dataflow.platform.inspector import Inspector
# Initialize once (singleton pattern)
kb = KnowledgeBase("patterns.yaml", "solutions.yaml")
inspector = Inspector(db)
debug_agent = DebugAgent(kb, inspector)
# Debug errors automatically
try:
runtime.execute(workflow.build())
except Exception as e:
report = debug_agent.debug(e, max_solutions=5, min_relevance=0.3)
print(report.to_cli_format()) # Rich terminal output
Output Formats:
# CLI format (color-coded, ANSI)
print(report.to_cli_format())
# JSON format (machine-readable)
json_output = report.to_json()
# Dictionary format (programmatic)
data = report.to_dict()
Performance: 5-50ms per error, 92%+ confidence for known patterns
Documentation:
- Skill Guide:
dataflow-debug-agent
- User Guide:
docs/guides/debug-agent-user-guide.md
- Developer Guide:
docs/guides/debug-agent-developer-guide.md
Build-Time Validation: Catch Errors Early
Validation Modes: OFF, WARN (default), STRICT
Catch 80% of configuration errors at model registration time (not runtime):
from dataflow import DataFlow
db = DataFlow("postgresql://...")
# Default: Warn mode (backward compatible)
@db.model
class User:
id: int # Validates: primary key named 'id'
name: str
email: str
# Strict mode: Raises errors on validation failures
@db.model(strict=True)
class Product:
id: int
name: str
price: float
# Skip validation (advanced users)
@db.model(skip_validation=True)
class Advanced:
custom_pk: int # Custom primary key allowed
Validation Checks:
- VAL-002: Missing primary key (error)
- VAL-003: Primary key not named 'id' (warning)
- VAL-004: Composite primary key (warning)
- VAL-005: Auto-managed field conflicts (created_at, updated_at)
- VAL-006: DateTime without timezone
- VAL-007: String/Text without length
- VAL-008: camelCase field names (should be snake_case)
- VAL-009: SQL reserved words as field names
- VAL-010: Missing delete cascade in relationships
When to Use Each Mode:
- OFF: Legacy code migration, custom implementations
- WARN (default): Development, catches issues without blocking
- STRICT: Production deployments, enforce standards
ErrorEnhancer: Actionable Error Messages
Automatic error enhancement with context, root causes, and solutions:
from dataflow import DataFlow
from dataflow.core.error_enhancer import ErrorEnhancer
db = DataFlow("postgresql://...")
# ErrorEnhancer automatically integrated into DataFlow engine
# Enhanced errors show:
# - Error code (DF-101, DF-102, etc.)
# - Context (node, parameters, workflow state)
# - Root causes with probability scores
# - Actionable solutions with code templates
# - Documentation links
try:
# Missing parameter error
workflow.add_node("UserCreateNode", "create", {})
except Exception as e:
# ErrorEnhancer automatically catches and enriches
# Shows: DF-101 with specific fixes
pass
Key Features:
- 40+ Error Codes: DF-101 (missing parameter) through DF-805 (runtime errors)
- Pattern Matching: Automatic error detection and classification
- Contextual Solutions: Code templates with variable substitution
- Color-Coded Output: Emojis and formatting for readability
- Documentation Links: Direct links to relevant guides
Common Errors Covered:
- DF-101: Missing required parameter
- DF-102: Type mismatch (expected dict, got str)
- DF-103: Auto-managed field conflict (created_at, updated_at)
- DF-104: Wrong node pattern (CreateNode vs UpdateNode)
- DF-105: Primary key 'id' missing/wrong name
- DF-201: Invalid connection - source output not found
- DF-301: Migration failed - table already exists
See: sdk-users/apps/dataflow/troubleshooting/top-10-errors.md
Inspector API: Self-Service Debugging
Introspection API for workflows, nodes, connections, and parameters:
from dataflow.platform.inspector import Inspector
inspector = Inspector(dataflow_instance)
inspector.workflow_obj = workflow.build()
# Connection Analysis
connections = inspector.connections() # List all connections
broken = inspector.find_broken_connections() # Find issues
validation = inspector.validate_connections() # Check validity
# Parameter Tracing
trace = inspector.trace_parameter("create_user", "data")
print(f"Source: {trace.source_node}")
dependencies = inspector.parameter_dependencies("create_user")
# Node Analysis
deps = inspector.node_dependencies("create_user") # Upstream
dependents = inspector.node_dependents("create_user") # Downstream
order = inspector.execution_order() # Topological sort
# Workflow Validation
report = inspector.workflow_validation_report()
if not report['is_valid']:
print(f"Errors: {report['errors']}")
print(f"Warnings: {report['warnings']}")
print(f"Suggestions: {report['suggestions']}")
# High-Level Overview
summary = inspector.workflow_summary()
metrics = inspector.workflow_metrics()
Inspector Methods (18 total):
- Connection Analysis (5): connections(), connection_chain(), connection_graph(), validate_connections(), find_broken_connections()
- Parameter Tracing (5): trace_parameter(), parameter_flow(), find_parameter_source(), parameter_dependencies(), parameter_consumers()
- Node Analysis (5): node_dependencies(), node_dependents(), execution_order(), node_schema(), compare_nodes()
- Workflow Analysis (3): workflow_summary(), workflow_metrics(), workflow_validation_report()
Use Cases:
- Diagnose "missing parameter" errors
- Find broken connections
- Trace parameter flow through workflows
- Validate workflows before execution
- Generate workflow documentation
- Debug complex workflows
Performance: <1ms per method call (cached operations)
CLI Tools: Industry-Standard Workflow Validation
Command-line tools matching pytest/mypy patterns for workflow validation and debugging:
# Validate workflow structure and connections
dataflow-validate workflow.py --output text
dataflow-validate workflow.py --fix # Auto-fix common issues
dataflow-validate workflow.py --output json > report.json
# Analyze workflow metrics and complexity
dataflow-analyze workflow.py --verbosity 2
dataflow-analyze workflow.py --format json
# Generate reports and documentation
dataflow-generate workflow.py report --output-dir ./reports
dataflow-generate workflow.py diagram # ASCII workflow diagram
dataflow-generate workflow.py docs --output-dir ./docs
# Debug workflows with breakpoints
dataflow-debug workflow.py --breakpoint create_user
dataflow-debug workflow.py --inspect-node create_user
dataflow-debug workflow.py --step # Step-by-step execution
# Profile performance and detect bottlenecks
dataflow-perf workflow.py --bottlenecks
dataflow-perf workflow.py --recommend
dataflow-perf workflow.py --format json > perf.json
CLI Commands (5 total):
- dataflow-validate: Validate workflow structure, connections, and parameters with --fix flag
- dataflow-analyze: Workflow metrics, complexity analysis, and execution order
- dataflow-generate: Generate reports, diagrams (ASCII), and documentation
- dataflow-debug: Interactive debugging with breakpoints and node inspection
- dataflow-perf: Performance profiling, bottleneck detection, and recommendations
Use Cases:
- CI/CD integration for workflow validation
- Pre-deployment validation checks
- Performance profiling and optimization
- Documentation generation
- Interactive debugging sessions
Performance: Industry-standard CLI tool performance (<100ms startup)
Common Pitfalls Guide
New: Comprehensive guides for common DataFlow mistakes
CreateNode vs UpdateNode (saves 1-2 hours):
- Side-by-side comparison
- Decision tree for node selection
- 10+ working examples
- Common mistakes and fixes
- See:
sdk-users/apps/dataflow/guides/create-vs-update.md
Top 10 Errors (saves 30-120 minutes per error):
- Quick fix guide for 90% of issues
- Error code reference (DF-101 through DF-805)
- Diagnosis decision tree
- Prevention checklist
- Inspector commands for debugging
- See:
sdk-users/apps/dataflow/troubleshooting/top-10-errors.md
Quick Start
from dataflow import DataFlow
from kailash.workflow.builder import WorkflowBuilder
from kailash.runtime.local import LocalRuntime
# Initialize DataFlow
db = DataFlow(connection_string="postgresql://user:pass@localhost/db")
# Define model (generates 11 nodes automatically)
@db.model
class User:
id: str # String IDs preserved
name: str
email: str
# Use generated nodes in workflows
workflow = WorkflowBuilder()
workflow.add_node("User_Create", "create_user", {
"data": {"name": "John", "email": "john@example.com"}
})
# Execute
runtime = LocalRuntime()
results, run_id = runtime.execute(workflow.build())
user_id = results["create_user"]["result"] # Access pattern
Reference Documentation
Getting Started
- dataflow-quickstart - Quick start guide and core concepts
- dataflow-installation - Installation and setup
- dataflow-models - Defining models with @db.model decorator
- dataflow-connection-config - Database connection configuration
Core Operations
- dataflow-crud-operations - Create, Read, Update, Delete operations
- dataflow-queries - Query patterns and filtering
- dataflow-bulk-operations - Batch operations for performance
- dataflow-transactions - Transaction management
- dataflow-connection-isolation - ⚠️ CRITICAL: Connection isolation and ACID guarantees
- dataflow-result-access - Accessing results from nodes
Advanced Features
- dataflow-multi-instance - Multiple database instances
- dataflow-multi-tenancy - Multi-tenant architectures
- dataflow-existing-database - Working with existing databases
- dataflow-migrations-quick - Database migrations
- dataflow-custom-nodes - Creating custom database nodes
- dataflow-performance - Performance optimization
Integration & Deployment
- dataflow-nexus-integration - Deploying with Nexus platform
- dataflow-deployment - Production deployment patterns
- dataflow-dialects - Supported database dialects
- dataflow-monitoring - Monitoring and observability
Testing & Quality
- dataflow-tdd-mode - Test-driven development with DataFlow
- dataflow-tdd-api - Testing API for DataFlow
- dataflow-tdd-best-practices - Testing best practices
- dataflow-compliance - Compliance and standards
Troubleshooting & Debugging
- create-vs-update guide - CreateNode vs UpdateNode comprehensive guide
- top-10-errors - Quick fix guide for 90% of issues
- dataflow-gotchas - Common pitfalls and solutions
- dataflow-strict-mode - Strict mode validation HOW-TO guide (Week 9)
- dataflow-validation-layers - 4-layer validation architecture (Week 9)
- dataflow-debug-agent - Intelligent error analysis with 5-stage pipeline (Week 10)
- ErrorEnhancer: Automatic error enhancement (integrated in DataFlow engine) - Enhanced in Week 7
- Inspector API: Self-service debugging (18 introspection methods)
- CLI Tools: Industry-standard command-line validation and debugging tools (5 commands)
Key Concepts
Not an ORM
DataFlow is NOT an ORM. It's a workflow framework that:
- Generates workflow nodes from models
- Operates within Kailash's workflow execution model
- Uses string-based result access patterns
- Integrates seamlessly with other workflow nodes
Automatic Node Generation
Each @db.model class generates 11 nodes:
{Model}_Create - Create single record
{Model}_Read - Read by ID
{Model}_Update - Update record
{Model}_Delete - Delete record
{Model}_List - List with filters
{Model}_Upsert - Insert or update (atomic)
{Model}_Count - Efficient COUNT(*) queries
{Model}_BulkCreate - Bulk insert
{Model}_BulkUpdate - Bulk update
{Model}_BulkDelete - Bulk delete
{Model}_BulkUpsert - Bulk upsert
Critical Rules
- ✅ String IDs preserved (no UUID conversion)
- ✅ Deferred schema operations (safe for Docker/FastAPI)
- ✅ Multi-instance isolation (one DataFlow per database)
- ✅ Result access:
results["node_id"]["result"]
- ❌ NEVER use truthiness checks on filter/data parameters (empty dict
{} is falsy)
- ❌ ALWAYS use key existence checks:
if "filter" in kwargs instead of if kwargs.get("filter")
- ❌ NEVER use direct SQL when DataFlow nodes exist
- ❌ NEVER use SQLAlchemy/Django ORM alongside DataFlow
Database Support
- SQL Databases: PostgreSQL, MySQL, SQLite (11 nodes per @db.model)
- Document Database: MongoDB with flexible schema (8 specialized nodes)
- Vector Search: PostgreSQL pgvector for RAG/AI (3 vector nodes)
- 100% Feature Parity: SQL databases support identical workflows
When to Use This Skill
Use DataFlow when you need to:
- Perform database operations in workflows
- Generate CRUD APIs automatically (with Nexus)
- Implement multi-tenant systems
- Work with existing databases
- Build database-first applications
- Handle bulk data operations
- Implement enterprise data management
Integration Patterns
With Nexus (Multi-Channel)
from dataflow import DataFlow
from nexus import Nexus
db = DataFlow(connection_string="...")
@db.model
class User:
id: str
name: str
# Auto-generates API + CLI + MCP
nexus = Nexus(db.get_workflows())
nexus.run() # Instant multi-channel platform
With Core SDK (Custom Workflows)
from dataflow import DataFlow
from kailash.workflow.builder import WorkflowBuilder
db = DataFlow(connection_string="...")
# Use db-generated nodes in custom workflows
workflow = WorkflowBuilder()
workflow.add_node("User_Create", "user1", {...})
Multi-Database Support Matrix
SQL Databases (DatabaseAdapter)
- PostgreSQL: Full support with advanced features (asyncpg driver, pgvector extension, native arrays)
- MySQL: Full support with 100% feature parity (aiomysql driver)
- SQLite: Full support for development/testing/mobile (aiosqlite + custom pooling)
- Nodes Generated: 11 per @db.model (Create, Read, Update, Delete, List, Upsert, Count, BulkCreate, BulkUpdate, BulkDelete, BulkUpsert)
Document Databases (MongoDBAdapter)
- MongoDB: Complete NoSQL support (Motor async driver)
- Features: Flexible schema, aggregation pipelines, text search, geospatial queries
- Workflow Nodes: 8 specialized nodes (DocumentInsert, DocumentFind, DocumentUpdate, DocumentDelete, BulkDocumentInsert, Aggregate, CreateIndex, DocumentCount)
- Use Cases: E-commerce catalogs, content management, user profiles, event logs
Vector Databases (PostgreSQLVectorAdapter)
- PostgreSQL pgvector: Semantic similarity search for RAG/AI (pgvector extension)
- Features: Cosine/L2/inner product distance, HNSW/IVFFlat indexes
- Workflow Nodes: 3 vector nodes (VectorSearch, VectorInsert, VectorUpdate)
- Use Cases: RAG applications, semantic search, recommendation engines
Architecture
- BaseAdapter: Minimal interface for all adapter types (adapter_type, database_type, health_check)
- DatabaseAdapter: SQL-specific (inherits BaseAdapter)
- MongoDBAdapter: Document database (inherits BaseAdapter)
- PostgreSQLVectorAdapter: Vector operations (inherits DatabaseAdapter)
Planned Extensions
- TimescaleDB: Time-series data optimization (PostgreSQL extension)
- Qdrant/Milvus: Dedicated vector databases with advanced filtering
- Redis: Caching and key-value operations
- Neo4j: Graph database with Cypher queries
Related Skills
Support
For DataFlow-specific questions, invoke:
dataflow-specialist - DataFlow implementation and patterns
testing-specialist - DataFlow testing strategies (NO MOCKING policy)
framework-advisor - Choose between Core SDK and DataFlow
1---
2name: dataflow
3description: "Kailash DataFlow - zero-config database framework with automatic model-to-node generation. Use when asking about 'database operations', 'DataFlow', 'database models', 'CRUD operations', 'bulk operations', 'database queries', 'database migrations', 'multi-tenancy', 'multi-instance', 'database transactions', 'PostgreSQL', 'MySQL', 'SQLite', 'MongoDB', 'pgvector', 'vector search', 'document database', 'RAG', 'semantic search', 'existing database', 'database performance', 'database deployment', 'database testing', or 'TDD with databases'. DataFlow is NOT an ORM - it generates 11 workflow nodes per SQL model, 8 nodes for MongoDB, and 3 nodes for vector operations."
4metadata:
5 source: https://skillmd.com/skills/aibot88/dataflow
6---
7
8# Kailash DataFlow - Zero-Config Database Framework
9
10DataFlow is a zero-config database framework built on Kailash Core SDK that automatically generates workflow nodes from database models.
11
12## Overview
13
14DataFlow transforms database models into workflow nodes automatically, providing:
15
16- **Automatic Node Generation**: 11 nodes per model (@db.model decorator)
17- **Multi-Database Support**: PostgreSQL, MySQL, SQLite (SQL) + MongoDB (Document) + pgvector (Vector Search)
18- **Enterprise Features**: Multi-tenancy, multi-instance isolation, transactions
19- **Zero Configuration**: String IDs preserved, deferred schema operations
20- **Integration Ready**: Works with Nexus for multi-channel deployment
21- **Specialized Adapters**: SQL (11 nodes/model), Document (8 nodes), Vector (3 nodes)
22L
23## 🛠️ Developer Experience Tools
24
25### Enhanced Error System
26
27DataFlow provides comprehensive error enhancement across all database operations, strict mode validation for build-time error prevention, and an intelligent debug agent for automated error diagnosis.
28
29#### Error Enhancement
30
31**What It Is**: Automatic transformation of Python exceptions into rich, actionable error messages with context, root causes, and solutions.
32
33**All DataFlow errors include**:
34- **Error codes**: DF-XXX format (DataFlow) or KS-XXX (Core SDK)
35- **Context**: Node, parameters, workflow state
36- **Root causes**: Why the error occurred (3-5 possibilities with probability scores)
37- **Solutions**: How to fix it (with code examples)
38
39**Example**:
40```python
41# Missing parameter error shows:
42# - Error Code: DF-101
43# - Missing parameter: "id"
44# - 3 solutions with code examples
45# - Link to documentation
46
47workflow.add_node("UserCreateNode", "create", {
48 "name": "Alice" # Missing "id" - error enhanced automatically
49})
50```
51
52**Error Categories**:
53- **DF-1XX**: Parameter errors (missing, type mismatch, validation)
54- **DF-2XX**: Connection errors (missing, circular, type mismatch)
55- **DF-3XX**: Migration errors (schema, constraints)
56- **DF-4XX**: Configuration errors (database URL, auth)
57- **DF-5XX**: Runtime errors (timeouts, resources)
58
59**Architecture**:
60```python
61# BaseErrorEnhancer - Shared abstraction
62# ├─ CoreErrorEnhancer - KS-501 to KS-508 (Core SDK)
63# └─ DataFlowErrorEnhancer - DF-XXX codes (DataFlow)
64```
65
66#### Strict Mode Validation
67
68**What It Is**: Build-time validation system with 4 layers to catch errors before workflow execution.
69
70**Validation Layers**:
711. **Model Validation** - Primary keys, auto-fields, reserved fields, field types
722. **Parameter Validation** - Required parameters, types, values, CreateNode structure
733. **Connection Validation** - Source/target nodes, type compatibility, dot notation
744. **Workflow Validation** - Structure, circular dependencies
75
76**Configuration**:
77```python
78from dataflow import DataFlow
79from dataflow.validation.strict_mode import StrictModeConfig
80
81config = StrictModeConfig(
82 enabled=True,
83 validate_models=True,
84 validate_parameters=True,
85 validate_connections=True,
86 validate_workflows=True,
87 fail_fast=True, # Stop on first error
88 verbose=False # Minimal output
89)
90
91db = DataFlow("postgresql://...", strict_mode_config=config)
92```
93
94**When to Use**:
95- ✅ Development: Catch errors early
96- ✅ CI/CD: Validate workflows before deployment
97- ✅ Production: Prevent invalid workflow execution
98
99**Documentation**:
100- HOW-TO Guide: [`dataflow-strict-mode`](dataflow-strict-mode.md)
101- Architecture Guide: [`dataflow-validation-layers`](dataflow-validation-layers.md)
102
103#### Debug Agent
104
105**What It Is**: Intelligent error analysis system that automatically diagnoses errors and provides ranked, actionable solutions.
106
107**5-Stage Pipeline**:
1081. **Capture** - Stack traces, context, error chains
1092. **Categorize** - 50+ patterns across 5 categories (PARAMETER, CONNECTION, MIGRATION, RUNTIME, CONFIGURATION)
1103. **Analyze** - Inspector integration for workflow analysis
1114. **Suggest** - 60+ solution templates with relevance scoring
1125. **Format** - CLI (color-coded), JSON (machine-readable), dict (programmatic)
113
114**Usage**:
115```python
116from dataflow.debug.debug_agent import DebugAgent
117from dataflow.debug.knowledge_base import KnowledgeBase
118from dataflow.platform.inspector import Inspector
119
120# Initialize once (singleton pattern)
121kb = KnowledgeBase("patterns.yaml", "solutions.yaml")
122inspector = Inspector(db)
123debug_agent = DebugAgent(kb, inspector)
124
125# Debug errors automatically
126try:
127 runtime.execute(workflow.build())
128except Exception as e:
129 report = debug_agent.debug(e, max_solutions=5, min_relevance=0.3)
130 print(report.to_cli_format()) # Rich terminal output
131```
132
133**Output Formats**:
134```python
135# CLI format (color-coded, ANSI)
136print(report.to_cli_format())
137
138# JSON format (machine-readable)
139json_output = report.to_json()
140
141# Dictionary format (programmatic)
142data = report.to_dict()
143```
144
145**Performance**: 5-50ms per error, 92%+ confidence for known patterns
146
147**Documentation**:
148- Skill Guide: [`dataflow-debug-agent`](dataflow-debug-agent.md)
149- User Guide: `docs/guides/debug-agent-user-guide.md`
150- Developer Guide: `docs/guides/debug-agent-developer-guide.md`
151
152---
153
154### Build-Time Validation: Catch Errors Early
155**Validation Modes**: OFF, WARN (default), STRICT
156
157Catch 80% of configuration errors at model registration time (not runtime):
158
159```python
160from dataflow import DataFlow
161
162db = DataFlow("postgresql://...")
163
164# Default: Warn mode (backward compatible)
165@db.model
166class User:
167 id: int # Validates: primary key named 'id'
168 name: str
169 email: str
170
171# Strict mode: Raises errors on validation failures
172@db.model(strict=True)
173class Product:
174 id: int
175 name: str
176 price: float
177
178# Skip validation (advanced users)
179@db.model(skip_validation=True)
180class Advanced:
181 custom_pk: int # Custom primary key allowed
182```
183
184**Validation Checks**:
185- **VAL-002**: Missing primary key (error)
186- **VAL-003**: Primary key not named 'id' (warning)
187- **VAL-004**: Composite primary key (warning)
188- **VAL-005**: Auto-managed field conflicts (created_at, updated_at)
189- **VAL-006**: DateTime without timezone
190- **VAL-007**: String/Text without length
191- **VAL-008**: camelCase field names (should be snake_case)
192- **VAL-009**: SQL reserved words as field names
193- **VAL-010**: Missing delete cascade in relationships
194
195**When to Use Each Mode**:
196- **OFF**: Legacy code migration, custom implementations
197- **WARN** (default): Development, catches issues without blocking
198- **STRICT**: Production deployments, enforce standards
199
200---
201
202### ErrorEnhancer: Actionable Error Messages
203
204Automatic error enhancement with context, root causes, and solutions:
205
206```python
207from dataflow import DataFlow
208from dataflow.core.error_enhancer import ErrorEnhancer
209
210db = DataFlow("postgresql://...")
211
212# ErrorEnhancer automatically integrated into DataFlow engine
213# Enhanced errors show:
214# - Error code (DF-101, DF-102, etc.)
215# - Context (node, parameters, workflow state)
216# - Root causes with probability scores
217# - Actionable solutions with code templates
218# - Documentation links
219
220try:
221 # Missing parameter error
222 workflow.add_node("UserCreateNode", "create", {})
223except Exception as e:
224 # ErrorEnhancer automatically catches and enriches
225 # Shows: DF-101 with specific fixes
226 pass
227```
228
229**Key Features**:
230- **40+ Error Codes**: DF-101 (missing parameter) through DF-805 (runtime errors)
231- **Pattern Matching**: Automatic error detection and classification
232- **Contextual Solutions**: Code templates with variable substitution
233- **Color-Coded Output**: Emojis and formatting for readability
234- **Documentation Links**: Direct links to relevant guides
235
236**Common Errors Covered**:
237- DF-101: Missing required parameter
238- DF-102: Type mismatch (expected dict, got str)
239- DF-103: Auto-managed field conflict (created_at, updated_at)
240- DF-104: Wrong node pattern (CreateNode vs UpdateNode)
241- DF-105: Primary key 'id' missing/wrong name
242- DF-201: Invalid connection - source output not found
243- DF-301: Migration failed - table already exists
244
245**See**: `sdk-users/apps/dataflow/troubleshooting/top-10-errors.md`
246
247---
248
249### Inspector API: Self-Service Debugging
250
251Introspection API for workflows, nodes, connections, and parameters:
252
253```python
254from dataflow.platform.inspector import Inspector
255
256inspector = Inspector(dataflow_instance)
257inspector.workflow_obj = workflow.build()
258
259# Connection Analysis
260connections = inspector.connections() # List all connections
261broken = inspector.find_broken_connections() # Find issues
262validation = inspector.validate_connections() # Check validity
263
264# Parameter Tracing
265trace = inspector.trace_parameter("create_user", "data")
266print(f"Source: {trace.source_node}")
267dependencies = inspector.parameter_dependencies("create_user")
268
269# Node Analysis
270deps = inspector.node_dependencies("create_user") # Upstream
271dependents = inspector.node_dependents("create_user") # Downstream
272order = inspector.execution_order() # Topological sort
273
274# Workflow Validation
275report = inspector.workflow_validation_report()
276if not report['is_valid']:
277 print(f"Errors: {report['errors']}")
278 print(f"Warnings: {report['warnings']}")
279 print(f"Suggestions: {report['suggestions']}")
280
281# High-Level Overview
282summary = inspector.workflow_summary()
283metrics = inspector.workflow_metrics()
284```
285
286**Inspector Methods** (18 total):
287- **Connection Analysis** (5): connections(), connection_chain(), connection_graph(), validate_connections(), find_broken_connections()
288- **Parameter Tracing** (5): trace_parameter(), parameter_flow(), find_parameter_source(), parameter_dependencies(), parameter_consumers()
289- **Node Analysis** (5): node_dependencies(), node_dependents(), execution_order(), node_schema(), compare_nodes()
290- **Workflow Analysis** (3): workflow_summary(), workflow_metrics(), workflow_validation_report()
291
292**Use Cases**:
293- Diagnose "missing parameter" errors
294- Find broken connections
295- Trace parameter flow through workflows
296- Validate workflows before execution
297- Generate workflow documentation
298- Debug complex workflows
299
300**Performance**: <1ms per method call (cached operations)
301
302---
303
304### CLI Tools: Industry-Standard Workflow Validation
305
306Command-line tools matching pytest/mypy patterns for workflow validation and debugging:
307
308```bash
309# Validate workflow structure and connections
310dataflow-validate workflow.py --output text
311dataflow-validate workflow.py --fix # Auto-fix common issues
312dataflow-validate workflow.py --output json > report.json
313
314# Analyze workflow metrics and complexity
315dataflow-analyze workflow.py --verbosity 2
316dataflow-analyze workflow.py --format json
317
318# Generate reports and documentation
319dataflow-generate workflow.py report --output-dir ./reports
320dataflow-generate workflow.py diagram # ASCII workflow diagram
321dataflow-generate workflow.py docs --output-dir ./docs
322
323# Debug workflows with breakpoints
324dataflow-debug workflow.py --breakpoint create_user
325dataflow-debug workflow.py --inspect-node create_user
326dataflow-debug workflow.py --step # Step-by-step execution
327
328# Profile performance and detect bottlenecks
329dataflow-perf workflow.py --bottlenecks
330dataflow-perf workflow.py --recommend
331dataflow-perf workflow.py --format json > perf.json
332```
333
334**CLI Commands** (5 total):
335- **dataflow-validate**: Validate workflow structure, connections, and parameters with --fix flag
336- **dataflow-analyze**: Workflow metrics, complexity analysis, and execution order
337- **dataflow-generate**: Generate reports, diagrams (ASCII), and documentation
338- **dataflow-debug**: Interactive debugging with breakpoints and node inspection
339- **dataflow-perf**: Performance profiling, bottleneck detection, and recommendations
340
341**Use Cases**:
342- CI/CD integration for workflow validation
343- Pre-deployment validation checks
344- Performance profiling and optimization
345- Documentation generation
346- Interactive debugging sessions
347
348**Performance**: Industry-standard CLI tool performance (<100ms startup)
349
350---
351
352### Common Pitfalls Guide
353**New**: Comprehensive guides for common DataFlow mistakes
354
355**CreateNode vs UpdateNode** (saves 1-2 hours):
356- Side-by-side comparison
357- Decision tree for node selection
358- 10+ working examples
359- Common mistakes and fixes
360- **See**: `sdk-users/apps/dataflow/guides/create-vs-update.md`
361
362**Top 10 Errors** (saves 30-120 minutes per error):
363- Quick fix guide for 90% of issues
364- Error code reference (DF-101 through DF-805)
365- Diagnosis decision tree
366- Prevention checklist
367- Inspector commands for debugging
368- **See**: `sdk-users/apps/dataflow/troubleshooting/top-10-errors.md`
369
370---
371
372## Quick Start
373
374```python
375from dataflow import DataFlow
376from kailash.workflow.builder import WorkflowBuilder
377from kailash.runtime.local import LocalRuntime
378
379# Initialize DataFlow
380db = DataFlow(connection_string="postgresql://user:pass@localhost/db")
381
382# Define model (generates 11 nodes automatically)
383@db.model
384class User:
385 id: str # String IDs preserved
386 name: str
387 email: str
388
389# Use generated nodes in workflows
390workflow = WorkflowBuilder()
391workflow.add_node("User_Create", "create_user", {
392 "data": {"name": "John", "email": "john@example.com"}
393})
394
395# Execute
396runtime = LocalRuntime()
397results, run_id = runtime.execute(workflow.build())
398user_id = results["create_user"]["result"] # Access pattern
399```
400
401## Reference Documentation
402
403### Getting Started
404- **[dataflow-quickstart](dataflow-quickstart.md)** - Quick start guide and core concepts
405- **[dataflow-installation](dataflow-installation.md)** - Installation and setup
406- **[dataflow-models](dataflow-models.md)** - Defining models with @db.model decorator
407- **[dataflow-connection-config](dataflow-connection-config.md)** - Database connection configuration
408
409### Core Operations
410- **[dataflow-crud-operations](dataflow-crud-operations.md)** - Create, Read, Update, Delete operations
411- **[dataflow-queries](dataflow-queries.md)** - Query patterns and filtering
412- **[dataflow-bulk-operations](dataflow-bulk-operations.md)** - Batch operations for performance
413- **[dataflow-transactions](dataflow-transactions.md)** - Transaction management
414- **[dataflow-connection-isolation](dataflow-connection-isolation.md)** - ⚠️ CRITICAL: Connection isolation and ACID guarantees
415- **[dataflow-result-access](dataflow-result-access.md)** - Accessing results from nodes
416
417### Advanced Features
418- **[dataflow-multi-instance](dataflow-multi-instance.md)** - Multiple database instances
419- **[dataflow-multi-tenancy](dataflow-multi-tenancy.md)** - Multi-tenant architectures
420- **[dataflow-existing-database](dataflow-existing-database.md)** - Working with existing databases
421- **[dataflow-migrations-quick](dataflow-migrations-quick.md)** - Database migrations
422- **[dataflow-custom-nodes](dataflow-custom-nodes.md)** - Creating custom database nodes
423- **[dataflow-performance](dataflow-performance.md)** - Performance optimization
424
425### Integration & Deployment
426- **[dataflow-nexus-integration](dataflow-nexus-integration.md)** - Deploying with Nexus platform
427- **[dataflow-deployment](dataflow-deployment.md)** - Production deployment patterns
428- **[dataflow-dialects](dataflow-dialects.md)** - Supported database dialects
429- **[dataflow-monitoring](dataflow-monitoring.md)** - Monitoring and observability
430
431### Testing & Quality
432- **[dataflow-tdd-mode](dataflow-tdd-mode.md)** - Test-driven development with DataFlow
433- **[dataflow-tdd-api](dataflow-tdd-api.md)** - Testing API for DataFlow
434- **[dataflow-tdd-best-practices](dataflow-tdd-best-practices.md)** - Testing best practices
435- **[dataflow-compliance](dataflow-compliance.md)** - Compliance and standards
436
437### Troubleshooting & Debugging
438- **[create-vs-update guide](../../../sdk-users/apps/dataflow/guides/create-vs-update.md)** - CreateNode vs UpdateNode comprehensive guide
439- **[top-10-errors](../../../sdk-users/apps/dataflow/troubleshooting/top-10-errors.md)** - Quick fix guide for 90% of issues
440- **[dataflow-gotchas](dataflow-gotchas.md)** - Common pitfalls and solutions
441- **[dataflow-strict-mode](dataflow-strict-mode.md)** - Strict mode validation HOW-TO guide (Week 9)
442- **[dataflow-validation-layers](dataflow-validation-layers.md)** - 4-layer validation architecture (Week 9)
443- **[dataflow-debug-agent](dataflow-debug-agent.md)** - Intelligent error analysis with 5-stage pipeline (Week 10)
444- **ErrorEnhancer**: Automatic error enhancement (integrated in DataFlow engine) - Enhanced in Week 7
445- **Inspector API**: Self-service debugging (18 introspection methods)
446- **CLI Tools**: Industry-standard command-line validation and debugging tools (5 commands)
447
448## Key Concepts
449
450### Not an ORM
451DataFlow is **NOT an ORM**. It's a workflow framework that:
452- Generates workflow nodes from models
453- Operates within Kailash's workflow execution model
454- Uses string-based result access patterns
455- Integrates seamlessly with other workflow nodes
456
457### Automatic Node Generation
458Each `@db.model` class generates **11 nodes**:
4591. `{Model}_Create` - Create single record
4602. `{Model}_Read` - Read by ID
4613. `{Model}_Update` - Update record
4624. `{Model}_Delete` - Delete record
4635. `{Model}_List` - List with filters
4646. `{Model}_Upsert` - Insert or update (atomic)
4657. `{Model}_Count` - Efficient COUNT(*) queries
4668. `{Model}_BulkCreate` - Bulk insert
4679. `{Model}_BulkUpdate` - Bulk update
46810. `{Model}_BulkDelete` - Bulk delete
46911. `{Model}_BulkUpsert` - Bulk upsert
470
471### Critical Rules
472- ✅ String IDs preserved (no UUID conversion)
473- ✅ Deferred schema operations (safe for Docker/FastAPI)
474- ✅ Multi-instance isolation (one DataFlow per database)
475- ✅ Result access: `results["node_id"]["result"]`
476- ❌ NEVER use truthiness checks on filter/data parameters (empty dict `{}` is falsy)
477- ❌ ALWAYS use key existence checks: `if "filter" in kwargs` instead of `if kwargs.get("filter")`
478- ❌ NEVER use direct SQL when DataFlow nodes exist
479- ❌ NEVER use SQLAlchemy/Django ORM alongside DataFlow
480
481### Database Support
482- **SQL Databases**: PostgreSQL, MySQL, SQLite (11 nodes per @db.model)
483- **Document Database**: MongoDB with flexible schema (8 specialized nodes)
484- **Vector Search**: PostgreSQL pgvector for RAG/AI (3 vector nodes)
485- **100% Feature Parity**: SQL databases support identical workflows
486
487## When to Use This Skill
488
489Use DataFlow when you need to:
490- Perform database operations in workflows
491- Generate CRUD APIs automatically (with Nexus)
492- Implement multi-tenant systems
493- Work with existing databases
494- Build database-first applications
495- Handle bulk data operations
496- Implement enterprise data management
497
498## Integration Patterns
499
500### With Nexus (Multi-Channel)
501```python
502from dataflow import DataFlow
503from nexus import Nexus
504
505db = DataFlow(connection_string="...")
506@db.model
507class User:
508 id: str
509 name: str
510
511# Auto-generates API + CLI + MCP
512nexus = Nexus(db.get_workflows())
513nexus.run() # Instant multi-channel platform
514```
515
516### With Core SDK (Custom Workflows)
517```python
518from dataflow import DataFlow
519from kailash.workflow.builder import WorkflowBuilder
520
521db = DataFlow(connection_string="...")
522# Use db-generated nodes in custom workflows
523workflow = WorkflowBuilder()
524workflow.add_node("User_Create", "user1", {...})
525```
526
527## Multi-Database Support Matrix
528
529### SQL Databases (DatabaseAdapter)
530- **PostgreSQL**: Full support with advanced features (asyncpg driver, pgvector extension, native arrays)
531- **MySQL**: Full support with 100% feature parity (aiomysql driver)
532- **SQLite**: Full support for development/testing/mobile (aiosqlite + custom pooling)
533- **Nodes Generated**: 11 per @db.model (Create, Read, Update, Delete, List, Upsert, Count, BulkCreate, BulkUpdate, BulkDelete, BulkUpsert)
534
535### Document Databases (MongoDBAdapter)
536- **MongoDB**: Complete NoSQL support (Motor async driver)
537- **Features**: Flexible schema, aggregation pipelines, text search, geospatial queries
538- **Workflow Nodes**: 8 specialized nodes (DocumentInsert, DocumentFind, DocumentUpdate, DocumentDelete, BulkDocumentInsert, Aggregate, CreateIndex, DocumentCount)
539- **Use Cases**: E-commerce catalogs, content management, user profiles, event logs
540
541### Vector Databases (PostgreSQLVectorAdapter)
542- **PostgreSQL pgvector**: Semantic similarity search for RAG/AI (pgvector extension)
543- **Features**: Cosine/L2/inner product distance, HNSW/IVFFlat indexes
544- **Workflow Nodes**: 3 vector nodes (VectorSearch, VectorInsert, VectorUpdate)
545- **Use Cases**: RAG applications, semantic search, recommendation engines
546
547### Architecture
548- **BaseAdapter**: Minimal interface for all adapter types (adapter_type, database_type, health_check)
549- **DatabaseAdapter**: SQL-specific (inherits BaseAdapter)
550- **MongoDBAdapter**: Document database (inherits BaseAdapter)
551- **PostgreSQLVectorAdapter**: Vector operations (inherits DatabaseAdapter)
552
553### Planned Extensions
554- **TimescaleDB**: Time-series data optimization (PostgreSQL extension)
555- **Qdrant/Milvus**: Dedicated vector databases with advanced filtering
556- **Redis**: Caching and key-value operations
557- **Neo4j**: Graph database with Cypher queries
558
559## Related Skills
560
561- **[01-core-sdk](../../01-core-sdk/SKILL.md)** - Core workflow patterns
562- **[03-nexus](../nexus/SKILL.md)** - Multi-channel deployment
563- **[04-kaizen](../kaizen/SKILL.md)** - AI agent integration
564- **[17-gold-standards](../../17-gold-standards/SKILL.md)** - Best practices
565
566## Support
567
568For DataFlow-specific questions, invoke:
569- `dataflow-specialist` - DataFlow implementation and patterns
570- `testing-specialist` - DataFlow testing strategies (NO MOCKING policy)
571- `framework-advisor` - Choose between Core SDK and DataFlow