# Tasks: Add Cycle Detection ## 1. Task Dependency Cycle Detection - [x] 1.1 Implement DFS-based cycle detection algorithm in dependency_service.py - [x] 1.2 Add validation hook when creating/updating task dependencies - [x] 1.3 Return 400 Bad Request with cycle path details when detected - [x] 1.4 Add cycle detection check in bulk dependency operations ## 2. Formula Field Cycle Detection - [x] 2.1 Parse formula field references to build dependency graph - [x] 2.2 Implement cycle detection for formula field references - [x] 2.3 Add validation when saving custom field formulas - [x] 2.4 Return descriptive error showing the cycle path ## 3. Frontend Feedback - [x] 3.1 Display user-friendly error message when cycle detected - [x] 3.2 Optionally highlight the problematic dependencies in UI ## 4. Testing - [x] 4.1 Add unit tests for cycle detection algorithm - [x] 4.2 Test direct circular dependency (A -> B -> A) - [x] 4.3 Test indirect circular dependency (A -> B -> C -> A) - [x] 4.4 Test formula field circular references