# Change: Add Cycle Detection for Task Dependencies and Formula Fields ## Why The system currently lacks detection for circular references in task dependencies and custom field formulas. This can lead to infinite loops during Gantt chart rendering or formula calculation, potentially causing application crashes or stack overflow errors. ## What Changes - Implement cycle detection algorithm (DFS/BFS) for task dependencies - Add cycle detection for formula field references - Return descriptive error when cycle is detected - Prevent saving of configurations that would create cycles ## Impact - Affected specs: task-management, automation - Affected code: - `backend/app/services/dependency_service.py` - Task dependency validation - `backend/app/services/formula_service.py` - Formula reference validation - `backend/app/api/task-dependencies/router.py` - API validation - `backend/app/api/custom-fields/router.py` - Field validation