884fefaab5
Tasks completed: 3/3 - Task 1: Create n8n-batch-ui.json sub-workflow (16 nodes) - Task 2: Update main workflow (192 -> 179 nodes, -13) - Task 3: Create backup for rollback SUMMARY: .planning/phases/10.1-aggressive-workflow-modularization/10.1-02-SUMMARY.md
149 lines
5.7 KiB
Markdown
149 lines
5.7 KiB
Markdown
---
|
|
phase: 10.1-aggressive-workflow-modularization
|
|
plan: 02
|
|
subsystem: workflow
|
|
tags: [n8n, modularization, sub-workflows, batch-ui, refactoring]
|
|
|
|
# Dependency graph
|
|
requires:
|
|
- phase: 10.1-01
|
|
provides: Domain boundary analysis and approved extraction plan
|
|
- phase: 10-workflow-modularization
|
|
provides: Existing sub-workflows (Update, Actions, Logs)
|
|
provides:
|
|
- n8n-batch-ui.json sub-workflow for batch selection UI
|
|
- Main workflow batch UI callback routing to sub-workflow
|
|
- Batch UI result handling with Telegram response dispatch
|
|
affects: [10.1-03, 10.1-04, 10.1-05]
|
|
|
|
# Tech tracking
|
|
tech-stack:
|
|
added: []
|
|
patterns:
|
|
- "Sub-workflow returns structured action/data, main workflow dispatches Telegram responses"
|
|
- "Route switch on sub-workflow action output for different response paths"
|
|
|
|
key-files:
|
|
created:
|
|
- n8n-batch-ui.json
|
|
- n8n-workflow.json.backup-batch
|
|
modified:
|
|
- n8n-workflow.json
|
|
|
|
key-decisions:
|
|
- "Extracted batch selection UI to sub-workflow while keeping execution loop in main"
|
|
- "Sub-workflow returns action type (keyboard/confirmation/execute/cancel/limit_reached) for routing"
|
|
- "Main workflow keeps Telegram response nodes per CONTEXT.md locked decision"
|
|
|
|
patterns-established:
|
|
- "Sub-workflow action-based routing: result.action determines Telegram response path"
|
|
- "Execute workflow placeholder pattern: TODO_DEPLOY_X_WORKFLOW for n8n import"
|
|
|
|
# Metrics
|
|
duration: ~8min
|
|
completed: 2026-02-05
|
|
---
|
|
|
|
# Phase 10.1 Plan 02: Batch UI Sub-workflow Summary
|
|
|
|
**Extracted batch selection UI logic to n8n-batch-ui.json sub-workflow, reducing main workflow from 192 to 179 nodes**
|
|
|
|
## Performance
|
|
|
|
- **Duration:** ~8 min
|
|
- **Started:** 2026-02-05T02:13:18Z
|
|
- **Completed:** 2026-02-05T02:20:00Z
|
|
- **Tasks:** 3
|
|
- **Files modified:** 3 (1 created, 2 modified)
|
|
|
|
## Accomplishments
|
|
|
|
- Created n8n-batch-ui.json sub-workflow with 16 nodes handling batch selection UI
|
|
- Reduced main workflow from 192 to 179 nodes (13 node reduction)
|
|
- Implemented action-based routing for sub-workflow results (keyboard/confirmation/execute/cancel/limit_reached)
|
|
- Maintained batch execution loop in main workflow (orchestration cannot be in sub-workflow)
|
|
- Created backup file for rollback capability
|
|
|
|
## Task Commits
|
|
|
|
Each task was committed atomically:
|
|
|
|
1. **Task 1: Create n8n-batch-ui.json sub-workflow** - `07a62d1` (feat)
|
|
2. **Task 2-3: Update main workflow and create backup** - `8b9af17` (feat)
|
|
|
|
**Plan metadata:** (this commit)
|
|
|
|
## Files Created/Modified
|
|
|
|
- `n8n-batch-ui.json` - New sub-workflow with 16 nodes for batch selection UI
|
|
- Execute Workflow Trigger for input
|
|
- Route Batch UI Action switch (mode/toggle/nav/exec/clear/cancel)
|
|
- Build/Rebuild Batch Keyboard nodes
|
|
- Handle Toggle/Nav/Exec/Clear/Cancel nodes
|
|
- Fetch Containers HTTP requests
|
|
- `n8n-workflow.json` - Updated main workflow
|
|
- Added: Prepare Batch UI Input, Execute Batch UI, Route Batch UI Result, 6 Telegram response nodes
|
|
- Removed: 22 batch UI nodes now in sub-workflow
|
|
- Updated: Route Callback batch outputs (14-19) to new sub-workflow path
|
|
- Updated: Prepare Batch Exec to accept sub-workflow output format
|
|
- `n8n-workflow.json.backup-batch` - Backup for rollback
|
|
|
|
## Decisions Made
|
|
|
|
1. **Partial extraction strategy:** Extracted batch selection UI while keeping execution loop in main workflow. The execution loop (Initialize Batch State -> Prepare Batch Loop -> ... -> Is Batch Complete) cannot be in sub-workflow due to n8n's sub-workflow limitations with loops back to caller.
|
|
|
|
2. **Action-based routing:** Sub-workflow returns an `action` field (keyboard/confirmation/execute/cancel/limit_reached) that main workflow routes to appropriate Telegram response handlers.
|
|
|
|
3. **Node count outcome:** Reduced from 192 to 179 nodes (13 reduction). Lower than planned 30-35 because:
|
|
- Batch execution loop (10+ nodes) must stay in main workflow
|
|
- Telegram response nodes (16) stay in main per CONTEXT.md
|
|
- Added 9 new infrastructure nodes for sub-workflow integration
|
|
|
|
## Deviations from Plan
|
|
|
|
### Auto-fixed Issues
|
|
|
|
**1. [Rule 3 - Blocking] Updated Prepare Batch Exec node for new input format**
|
|
- **Found during:** Task 2 (main workflow update)
|
|
- **Issue:** Prepare Batch Exec referenced removed node "Prepare Immediate Batch Exec"
|
|
- **Fix:** Updated node to accept sub-workflow output format directly
|
|
- **Files modified:** n8n-workflow.json
|
|
- **Verification:** Node code updated to handle new data structure
|
|
- **Committed in:** 8b9af17 (Task 2-3 commit)
|
|
|
|
---
|
|
|
|
**Total deviations:** 1 auto-fixed (1 blocking)
|
|
**Impact on plan:** Auto-fix was necessary for correct data flow. No scope creep.
|
|
|
|
## Issues Encountered
|
|
|
|
1. **Lower node reduction than planned:** Plan expected 30-35 node reduction, achieved 13. This is because:
|
|
- Batch execution loop cannot be extracted (n8n sub-workflow limitation)
|
|
- Telegram response nodes locked to main workflow per CONTEXT.md
|
|
- New infrastructure nodes needed for sub-workflow integration
|
|
|
|
2. **Complex data flow refactoring:** Had to carefully update data references after removing nodes that were referenced by others.
|
|
|
|
## User Setup Required
|
|
|
|
**Deployment steps required.** After importing sub-workflow to n8n:
|
|
|
|
1. Import `n8n-batch-ui.json` to n8n instance
|
|
2. Note the assigned workflow ID
|
|
3. Update `n8n-workflow.json`: Replace `TODO_DEPLOY_BATCH_UI_WORKFLOW` with actual ID
|
|
4. Re-import main workflow
|
|
|
|
## Next Phase Readiness
|
|
|
|
Ready to proceed with Plan 10.1-03: Container List Sub-workflow extraction.
|
|
|
|
**Notes for next plan:**
|
|
- Same pattern: sub-workflow returns structured data, main handles Telegram responses
|
|
- Container List domain has 17 nodes per analysis, expect 12-15 node reduction
|
|
- Watch for similar data flow dependencies
|
|
|
|
---
|
|
*Phase: 10.1-aggressive-workflow-modularization*
|
|
*Completed: 2026-02-05*
|