Skip to content

Latest commit

 

History

History
127 lines (96 loc) · 3.27 KB

File metadata and controls

127 lines (96 loc) · 3.27 KB

Task Dependencies Implementation

Branch

feature/task-dependencies

Changes Made

Contract Layer (Rust)

File: contract/src/lib.rs

  1. Added new error types:

    • SelfDependency (8)
    • DependencyNotFound (9)
    • CircularDependency (10)
    • DependencyBlocked (11)
  2. Extended TaskConfig struct:

    • Added blocked_by: Vec<u64> field
  3. Added TaskDependencies to DataKey enum

  4. New contract functions:

    • add_dependency(task_id, depends_on_task_id) - Creates blocking relationship
    • remove_dependency(task_id, depends_on_task_id) - Removes blocking relationship
    • get_dependencies(task_id) - Returns list of blocking tasks
    • is_task_blocked(task_id) - Checks if task has incomplete dependencies
    • would_create_cycle() - DFS-based circular dependency detection
    • has_path_to() - Helper for cycle detection
  5. Updated execute() function:

    • Added dependency check before execution
    • Panics with DependencyBlocked if dependencies incomplete
  6. Added comprehensive tests:

    • Dependency add/remove
    • Self-dependency prevention
    • Circular dependency detection
    • Blocked task execution
    • Dependency state checking

Frontend Layer (TypeScript/React)

New Components:

  1. frontend/components/TaskDependencyManager.tsx

    • Dependency list display with status badges
    • Add dependency dropdown
    • Remove dependency buttons
    • Error handling
  2. frontend/components/TaskCard.tsx

    • Task summary card
    • Blocked status indicator
    • Dependency count badge
    • Click to view details
  3. frontend/components/TaskDetailModal.tsx

    • Full task details view
    • Integrated dependency manager
    • Task status indicators
  4. frontend/app/page.tsx

    • Updated dashboard with task cards
    • Blocked tasks alert banner
    • Mock data and handlers (ready for contract integration)

Tests:

File: frontend/__tests__/TaskDependencyManager.test.tsx

  • 8 test cases covering all functionality
  • All tests passing

Configuration Updates:

  • frontend/tsconfig.json - Updated jsx mode to "preserve"
  • frontend/jest.config.js - Fixed test paths for new structure

Documentation

File: docs/task-dependencies.md

  • Complete feature documentation
  • API reference
  • Usage examples
  • Best practices
  • Error codes reference

Acceptance Criteria Status

✅ Users can create and remove task dependencies ✅ Blocked state is visible in relevant task views ✅ Invalid relationships are prevented or clearly handled ✅ The feature fits naturally into existing task workflows ✅ Tests cover dependency creation, removal, and edge cases

Testing

Contract Tests

cd contract
cargo test

All dependency tests passing:

  • test_add_dependency
  • test_remove_dependency
  • test_self_dependency_prevented
  • test_circular_dependency_prevented
  • test_task_blocked_by_dependency
  • test_execute_fails_when_blocked
  • test_dependency_not_found

Frontend Tests

cd frontend
pnpm test

All 8 tests passing in TaskDependencyManager.test.tsx

Next Steps

  1. Deploy updated contract to testnet
  2. Integrate frontend with actual contract calls
  3. Add keeper logic to respect dependencies
  4. Update event indexing for dependency events
  5. Add dependency visualization (graph view)