Phase 10: Workflow Modularization - 4 plan(s) in 3 wave(s) - Wave 1: Orphan cleanup (1 plan) - Wave 2: Sub-workflow extraction (2 plans parallel) - Wave 3: Integration verification (1 plan) - Ready for execution Plans: - 10-01: Remove 8 orphan nodes - 10-02: Extract container-update sub-workflow (DEBT-03) - 10-03: Extract container-actions sub-workflow - 10-04: Integration verification with user checkpoint Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
7.7 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 | 02 | execute | 2 |
|
|
true |
|
Purpose: The update logic is currently duplicated between the text command path (~lines 1656-2400) and the callback/inline keyboard path (~lines 3628-4010). Extracting to a sub-workflow creates a single source of truth, reduces main workflow complexity, and makes the update logic independently testable.
Output: New container-update sub-workflow JSON file and updated main workflow that calls it from both text and callback paths.
<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-RESEARCH.md @.planning/phases/10-workflow-modularization/10-01-SUMMARY.md @n8n-workflow.json Task 1: Create container-update sub-workflow n8n-container-update.json Create a new sub-workflow file `n8n-container-update.json` that encapsulates the entire container update flow.Input contract (Execute Sub-workflow Trigger with defined fields):
{
"containerId": "string - Docker container ID",
"containerName": "string - Container name for messages",
"chatId": "number - Telegram chat ID",
"messageId": "number - Message ID for inline edits (0 for text mode)",
"responseMode": "string - 'text' or 'inline'"
}
Flow to extract (from research):
- Inspect container configuration (get current image, config, host config)
- Pull latest image (with :latest tag protection)
- Inspect new image and compare digests
- If update needed:
- Stop container
- Remove old container
- Create new container with same config
- Start new container
- Clean up old image
- Return result
Output contract:
{
"success": "boolean",
"message": "string - Result message for user",
"updated": "boolean - Whether update was performed",
"oldDigest": "string (optional)",
"newDigest": "string (optional)"
}
Implementation notes:
- Use "Define using fields" schema type for input contract (per research best practice)
- Include progress message editing for inline mode (messageId > 0)
- Include new message sending for text mode (messageId == 0)
- Handle both "update needed" and "already up to date" cases
- Preserve :latest tag protection (default to :latest if no tag)
- Preserve image cleanup after successful update
- JSON file is valid:
python3 -c "import json; json.load(open('n8n-container-update.json'))" - Contains "executeWorkflowTrigger" node
- Has proper input schema with all 5 fields Container update sub-workflow created with proper input/output contracts
Changes needed:
-
Text command path:
- Find the text update flow (around the "Update Container" text command routing)
- Replace inline update nodes with: a. Code node to prepare sub-workflow input (containerId, containerName, chatId, messageId=0, responseMode='text') b. Execute Sub-workflow node pointing to container-update workflow
- Remove the duplicate update logic nodes from text path
-
Callback/inline path:
- Find the callback update flow (around "Handle Update Action" or similar)
- Replace inline update nodes with: a. Code node to prepare sub-workflow input (containerId, containerName, chatId, messageId from callback, responseMode='inline') b. Execute Sub-workflow node pointing to container-update workflow
- Remove the duplicate update logic nodes from callback path
-
Batch update path:
- Find where batch update calls individual container updates
- Ensure it also uses the sub-workflow (may already be structured to call the same code)
Execute Sub-workflow node configuration:
{
"parameters": {
"source": "database",
"workflowId": "<will be set after import>",
"mode": "once",
"options": {
"waitForSubWorkflow": true
}
},
"type": "n8n-nodes-base.executeWorkflow"
}
Important: After extraction, the main workflow should be significantly shorter (estimate ~750 fewer lines per research).
- Main workflow JSON is valid
- Contains "executeWorkflow" node(s) for update paths
- Old inline update nodes are removed (workflow is shorter) Main workflow updated to call container-update sub-workflow from all update paths
Deployment steps:
- Import container-update sub-workflow to n8n via API (create new workflow)
- Note the workflow ID assigned by n8n
- Update main workflow's Execute Sub-workflow node(s) with correct workflow ID
- Deploy main workflow update to n8n via API
Verification tests:
-
Text command update:
- Send "update " to bot
- Should show update confirmation prompt
- Confirm and verify update completes (or shows "already up to date")
-
Inline keyboard update:
- Use /status to get container list
- Select a container
- Tap "Update" button
- Should show confirmation dialog
- Confirm and verify update completes with progress messages
-
Batch update (if time permits):
- Initiate a batch update for 2 containers
- Verify both update correctly
- Sub-workflow imported and has valid ID in n8n
- Main workflow deployed with correct sub-workflow reference
- Text "update " command works
- Inline keyboard update flow works
- Progress messages display correctly Update sub-workflow deployed and all update paths verified working
<success_criteria>
- Container update logic exists in ONE place (sub-workflow)
- Both text and inline update paths use the sub-workflow
- DEBT-03 (duplicated update flow) resolved
- All update functionality works as before </success_criteria>