taskgenius_taskgenius-plugin/docs/dataflow-migration-phase-a-complete.md
Quorafind ac682e5792 refactor(architecture): complete dataflow migration and file reorganization
Major architectural improvements:
- Created DataflowBridge for MCP integration with conditional switching
- Moved core parsers from utils/ to dataflow/core/ for better organization
- Consolidated workers under dataflow/workers/ directory
- Removed deprecated files (filterUtils, projectFilter, TaskManagerBridge)
- Deleted integration test files no longer needed

File organization changes:
- utils/parsing/* → dataflow/core/ (CoreTaskParser, CanvasParser)
- utils/workers/* → dataflow/core/ and dataflow/workers/
- Removed 11 deprecated/duplicate files
- Updated all import paths across the codebase

Architecture benefits:
- Clear separation between utils (tools) and dataflow (task processing)
- Unified worker management under dataflow architecture
- Conditional MCP bridge selection based on dataflowEnabled setting
- Cleaner module boundaries and dependencies

Documentation:
- Added comprehensive dataflow-architecture.md
- Documents new structure, migration status, and usage guidelines
- Provides rollback procedures and development guidelines
2025-08-19 07:27:37 +08:00

3.5 KiB

Dataflow Migration - Phase A Complete

Summary

Phase A of the dataflow migration has been successfully implemented. This phase enables parallel initialization of both the traditional TaskManager and the new dataflow architecture, with experimental user control.

Completed Tasks

A1: Experimental Settings Switch

  • Location: src/common/setting-definition.ts, src/setting.ts
  • Changes:
    • Added experimental.dataflowEnabled setting with default false
    • Created new "Experimental" tab in settings UI
    • Added warning messages and user-friendly descriptions
    • Added CSS styles for experimental settings

A2: Parallel Initialization

  • Location: src/index.ts, src/dataflow/createDataflow.ts
  • Changes:
    • Created createDataflow() factory function
    • Added isDataflowEnabled() utility function
    • Modified plugin onload() to conditionally initialize dataflow
    • Added proper cleanup in onunload()
    • Both systems run in parallel when dataflow is enabled

A3: TaskView Data Source Selection

  • Location: src/pages/TaskView.ts
  • Changes:
    • Modified loadTasks() method to check dataflow availability
    • Modified loadTasksFast() method with same logic
    • Added fallback mechanism to TaskManager if dataflow fails
    • Maintained backward compatibility

Key Features

Safe Experimentation

  • Users can enable/disable dataflow through settings
  • Automatic fallback to TaskManager on any dataflow errors
  • Both systems can run simultaneously for comparison

Non-Breaking Changes

  • All existing functionality preserved
  • No changes to default behavior (dataflow disabled by default)
  • Graceful error handling

Ready for Testing

  • TaskView now conditionally uses QueryAPI when dataflow is enabled
  • Console logging for debugging and verification
  • Clean separation between old and new systems

Testing Instructions

  1. Enable Dataflow:

    • Go to Settings → Advanced → Experimental
    • Toggle "Enable Dataflow Architecture"
    • Restart plugin (recommended)
  2. Verify Operation:

    • Open Task Genius view
    • Check console for messages:
      • "Loading tasks from dataflow orchestrator..." (dataflow enabled)
      • "TaskView loaded X tasks from dataflow" (success)
      • "Loading tasks from TaskManager" (fallback/disabled)
  3. Test Fallback:

    • If dataflow fails, should automatically fall back to TaskManager
    • No user-visible errors should occur

Next Phase Recommendations

Phase B: View Migration

  • Migrate remaining views (Projects, Tags, Forecast)
  • Add more sophisticated error handling
  • Implement data consistency checks

Phase C: Feature Parity

  • Ensure all TaskManager features work with dataflow
  • Performance comparison and optimization
  • User feedback collection

Code Locations

src/common/setting-definition.ts    # Settings definition
src/setting.ts                      # Settings UI
src/styles/setting.css              # Experimental settings styles
src/index.ts                        # Plugin initialization
src/dataflow/createDataflow.ts      # Dataflow factory
src/pages/TaskView.ts               # Main view with conditional data source

Architecture Notes

The implementation maintains clean separation:

  • Settings Layer: Controls experimental features
  • Initialization Layer: Manages parallel system startup
  • Data Layer: Provides conditional data source selection
  • UI Layer: Unchanged, works with both systems

This approach allows for gradual migration with minimal risk and easy rollback capabilities.