Wave 4 plan to finish workflow modularization: - Wire batch update to Container Update sub-workflow - Wire batch actions to Container Actions sub-workflow - Extract logs flow to new Container Logs sub-workflow - Target: reduce main workflow from 209 to ~120-140 nodes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
9.1 KiB
phase, plan, type, wave, depends_on, files_modified, autonomous, must_haves
| phase | plan | type | wave | depends_on | files_modified | autonomous | must_haves | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 10-workflow-modularization | 05 | execute | 4 |
|
|
true |
|
Purpose: The main workflow is still 209 nodes with significant duplication. Batch operations duplicate logic that exists in sub-workflows. Logs flow is self-contained and should be extracted. Target: reduce main workflow to ~120-140 nodes while maintaining all functionality.
Output: Streamlined main workflow using sub-workflows for all container operations, plus new logs sub-workflow.
<execution_context> @/home/luc/.claude/get-shit-done/workflows/execute-plan.md @/home/luc/.claude/get-shit-done/templates/summary.md </execution_context>
@.planning/PROJECT.md @.planning/ROADMAP.md @.planning/phases/10-workflow-modularization/10-01-SUMMARY.md @.planning/phases/10-workflow-modularization/10-02-SUMMARY.md @.planning/phases/10-workflow-modularization/10-03-SUMMARY.md @.planning/phases/10-workflow-modularization/10-04-SUMMARY.md @n8n-workflow.json @n8n-container-update.json @n8n-container-actions.json Task 1: Wire batch update to Container Update sub-workflow n8n-workflow.json Replace inline batch update logic with calls to the existing Container Update sub-workflow.Current state:
- Batch update has its own inline logic (Prepare Update All Batch, etc.)
- Single update uses Container Update sub-workflow
- This creates duplication
Changes needed:
-
Find batch update execution path (around "Prepare Update All Batch", batch loop nodes)
-
Replace inline update logic with:
- Loop/SplitInBatches node to iterate over containers
- Execute Sub-workflow node calling Container Update for each container
- Aggregate results
-
Remove redundant nodes:
- Any batch-specific update execution nodes
- Duplicate Docker API calls for update
- Keep: batch UI, confirmation, progress display nodes
Input to sub-workflow (per container):
{
"containerId": "from batch list",
"containerName": "from batch list",
"chatId": "from batch context",
"messageId": "for progress updates",
"responseMode": "inline"
}
Key principle: The sub-workflow handles the actual update. Main workflow handles:
- Batch selection/confirmation UI
- Loop orchestration
- Progress aggregation/display
- Batch update path calls Execute Sub-workflow with Container Update workflow ID
- No duplicate update logic remains in main workflow for batch path
- Batch update still works end-to-end Batch update wired to use Container Update sub-workflow
Current state (25 batch action nodes):
- Execute Batch Action, Execute Batch Container Action, Execute Batch Action 2
- Route Batch Action, Route Batch Loop Action
- Build Batch Action Command, etc.
- These duplicate logic in Container Actions sub-workflow
Changes needed:
-
Find batch action execution paths
-
Replace inline action logic with:
- Loop/SplitInBatches to iterate over selected containers
- Execute Sub-workflow node calling Container Actions for each
- Aggregate results
-
Remove redundant nodes:
- Execute Batch Action, Execute Batch Container Action
- Build Batch Action Command
- Route Batch Loop Action (if only routing to inline execution)
- Keep: batch UI, confirmation dialogs, progress display
Input to sub-workflow (per container):
{
"containerId": "from batch list",
"containerName": "from batch list",
"action": "start|stop|restart",
"chatId": "from batch context",
"messageId": "for progress updates",
"responseMode": "inline"
}
Estimated node reduction: ~15-20 nodes removed
- Batch start/stop/restart paths call Execute Sub-workflow with Container Actions workflow ID
- No duplicate action execution logic in main workflow
- Batch actions still work end-to-end Batch actions wired to use Container Actions sub-workflow
Current logs nodes (17 total):
- Parse Logs Command
- Docker List for Logs
- Match Logs Container
- Check Logs Match Count
- Build Logs Command
- Execute Logs
- Format Logs
- Send Logs Response/Error
- Format Logs No Match/Multiple
- Prepare Logs Action
- Get Container For Logs
- Build Logs Action Command
- Execute Logs Action
- Format Logs Action Result
- Send Logs Result
Create n8n-container-logs.json:
Input contract:
{
"containerId": "string - Docker container ID (optional if using name)",
"containerName": "string - Container name for matching",
"lineCount": "number - Number of log lines (default 50)",
"chatId": "number - Telegram chat ID",
"messageId": "number - Message ID for inline edits (0 for text mode)",
"responseMode": "string - 'text' or 'inline'"
}
Output contract:
{
"success": "boolean",
"message": "string - Formatted logs or error message",
"containerName": "string",
"lineCount": "number"
}
Sub-workflow flow:
- If containerId provided, use directly; else match by name
- Execute docker logs command
- Format output (truncate if needed, add header)
- Return formatted result
Main workflow changes:
- Replace 17 logs nodes with:
- Code node to prepare sub-workflow input
- Execute Sub-workflow node
- Handle result (send message)
- Keep: Routing to logs path, final message sending
Estimated reduction: 17 nodes -> ~3-4 nodes in main + 10-12 in sub-workflow
- n8n-container-logs.json exists and is valid
- Main workflow has Execute Sub-workflow node for logs
- Text "logs " command works
- Inline keyboard logs button works
- "logs 100" (with line count) works Logs flow extracted to sub-workflow and deployed
-
Remove orphaned nodes:
- Any nodes no longer connected after refactoring
- Duplicate/vestigial nodes from prior iterations
-
Verify node count:
- Target: ~120-140 nodes in main workflow
- Document actual reduction achieved
-
Deploy all workflows to n8n:
- Import n8n-container-logs.json (new)
- Update main workflow
- Verify all three sub-workflows are active
-
Test all paths:
- Single update (text + inline)
- Batch update
- Single actions (start/stop/restart via text + inline)
- Batch actions
- Logs (text + inline)
-
Document final architecture:
Main Workflow (n8n-workflow.json) ├── Telegram Trigger + Auth ├── Command Routing ├── Confirmation Dialogs ├── Batch UI/Selection └── Sub-workflow Orchestration ├── Container Update (all update operations) ├── Container Actions (all start/stop/restart) └── Container Logs (all logs operations)
<success_criteria>
- Main workflow is manageable size (~120-140 nodes)
- All container operations routed through 3 sub-workflows
- No code duplication between single and batch paths
- All existing functionality preserved </success_criteria>