From b83f76b27bf1a7073354683a97df47a1cfe7b8d8 Mon Sep 17 00:00:00 2001 From: Lucas Berger Date: Wed, 4 Feb 2026 13:43:09 -0500 Subject: [PATCH] docs(10): add plan 10-05 for complete modularization 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 --- .planning/ROADMAP.md | 15 +- .../10-workflow-modularization/10-05-PLAN.md | 297 ++++++++++++++++++ 2 files changed, 306 insertions(+), 6 deletions(-) create mode 100644 .planning/phases/10-workflow-modularization/10-05-PLAN.md diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 5ed4e69..09f9168 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -20,19 +20,22 @@ Modularize the workflow for maintainability, add "update all" functionality, fix **Requirements:** MOD-01, MOD-02, DEBT-03 -**Plans:** 4 plans +**Plans:** 5 plans Plans: -- [ ] 10-01-PLAN.md — Orphan node cleanup (remove 8 orphan nodes before modularization) -- [ ] 10-02-PLAN.md — Extract container update sub-workflow (consolidates DEBT-03) -- [ ] 10-03-PLAN.md — Extract container actions sub-workflow (start/stop/restart) +- [x] 10-01-PLAN.md — Orphan node cleanup (removed 2 orphan nodes) +- [x] 10-02-PLAN.md — Extract container update sub-workflow (consolidates DEBT-03) +- [x] 10-03-PLAN.md — Extract container actions sub-workflow (start/stop/restart) - [ ] 10-04-PLAN.md — Integration verification and user checkpoint +- [ ] 10-05-PLAN.md — Complete modularization (batch operations, logs sub-workflow) **Success Criteria:** -1. Workflow split into logical sub-workflows (command routing, container operations, keyboard generation, etc.) +1. Workflow split into logical sub-workflows (update, actions, logs) 2. Sub-workflows callable from main without code duplication 3. Update flow consolidated between single and batch paths -4. All existing functionality still works after modularization +4. Actions flow consolidated between single and batch paths +5. Main workflow reduced from 209 to ~120-140 nodes +6. All existing functionality still works after modularization --- diff --git a/.planning/phases/10-workflow-modularization/10-05-PLAN.md b/.planning/phases/10-workflow-modularization/10-05-PLAN.md new file mode 100644 index 0000000..9e5ebb4 --- /dev/null +++ b/.planning/phases/10-workflow-modularization/10-05-PLAN.md @@ -0,0 +1,297 @@ +--- +phase: 10-workflow-modularization +plan: 05 +type: execute +wave: 4 +depends_on: [10-04] +files_modified: [n8n-workflow.json, n8n-container-logs.json] +autonomous: true + +must_haves: + truths: + - "Batch update uses Container Update sub-workflow" + - "Batch actions use Container Actions sub-workflow" + - "Logs flow extracted to sub-workflow" + - "Main workflow reduced to ~120-140 nodes" + artifacts: + - path: "n8n-container-logs.json" + provides: "Container logs sub-workflow" + contains: "executeWorkflowTrigger" + - path: "n8n-workflow.json" + provides: "Streamlined main workflow" + max_nodes: 150 + key_links: + - from: "n8n-workflow.json" + to: "n8n-container-logs.json" + via: "Execute Sub-workflow node" + pattern: "executeWorkflow" +--- + + +Complete workflow modularization by wiring batch operations to existing sub-workflows and extracting the logs flow. + +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. + + + +@/home/luc/.claude/get-shit-done/workflows/execute-plan.md +@/home/luc/.claude/get-shit-done/templates/summary.md + + + +@.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:** + +1. Find batch update execution path (around "Prepare Update All Batch", batch loop nodes) + +2. Replace inline update logic with: + - Loop/SplitInBatches node to iterate over containers + - Execute Sub-workflow node calling Container Update for each container + - Aggregate results + +3. 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):** +```json +{ + "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 + + + + Task 2: Wire batch actions to Container Actions sub-workflow + n8n-workflow.json + +Replace inline batch action logic with calls to the existing Container Actions 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:** + +1. Find batch action execution paths + +2. Replace inline action logic with: + - Loop/SplitInBatches to iterate over selected containers + - Execute Sub-workflow node calling Container Actions for each + - Aggregate results + +3. 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):** +```json +{ + "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 + + + + Task 3: Extract logs flow to sub-workflow + n8n-workflow.json, n8n-container-logs.json + +Create a new Container Logs sub-workflow and wire the main workflow to use it. + +**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: +```json +{ + "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: +```json +{ + "success": "boolean", + "message": "string - Formatted logs or error message", + "containerName": "string", + "lineCount": "number" +} +``` + +**Sub-workflow flow:** +1. If containerId provided, use directly; else match by name +2. Execute docker logs command +3. Format output (truncate if needed, add header) +4. Return formatted result + +**Main workflow changes:** +1. Replace 17 logs nodes with: + - Code node to prepare sub-workflow input + - Execute Sub-workflow node + - Handle result (send message) +2. 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 + + + + Task 4: Clean up and deploy + n8n-workflow.json, n8n-container-logs.json + +Final cleanup and deployment of all workflow changes. + +1. **Remove orphaned nodes:** + - Any nodes no longer connected after refactoring + - Duplicate/vestigial nodes from prior iterations + +2. **Verify node count:** + - Target: ~120-140 nodes in main workflow + - Document actual reduction achieved + +3. **Deploy all workflows to n8n:** + - Import n8n-container-logs.json (new) + - Update main workflow + - Verify all three sub-workflows are active + +4. **Test all paths:** + - Single update (text + inline) + - Batch update + - Single actions (start/stop/restart via text + inline) + - Batch actions + - Logs (text + inline) + +5. **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) + ``` + + +- Main workflow node count: 120-150 nodes +- All functionality works +- No orphan nodes +- Architecture documented in SUMMARY + + Modularization complete, all workflows deployed and verified + + + + + +1. Main workflow reduced from 209 to ~120-140 nodes +2. Batch update uses Container Update sub-workflow +3. Batch actions use Container Actions sub-workflow +4. Logs flow uses new Container Logs sub-workflow +5. All text commands work (status, start, stop, restart, update, logs) +6. All inline keyboard flows work +7. All batch operations work +8. No duplicate container operation logic in main workflow + + + +- 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 + + + +After completion, create `.planning/phases/10-workflow-modularization/10-05-SUMMARY.md` +