Commit Graph

358 Commits

Author SHA1 Message Date
Lucas Berger 13ed81cccf feat(10.1-03): update main workflow to call status sub-workflow
- Removed 10 list/status nodes (Docker queries, keyboard building)
- Added 9 integration nodes (Prepare/Execute pairs for status, select, paginate)
- Keyword Router status output -> Prepare Status Input -> Execute Container Status
- Answer Select Callback -> Execute Select Status -> Send Container Submenu
- Answer List Callback -> Execute Paginate Status -> Edit Container List
- Prepare Batch Cancel Return -> Execute Batch Cancel Status -> Edit Container List
- Added TODO_DEPLOY_STATUS_WORKFLOW placeholder for deployment
2026-02-04 21:26:55 -05:00
Lucas Berger 369eb2a87e feat(10.1-03): create container status sub-workflow
- Created n8n-status.json with 11 nodes
- Handles list, status, and paginate actions
- Input: chatId, messageId, action, containerName, page, queryId, searchTerm
- Output: success, action, text, reply_markup, container data
- Docker queries via HTTP request to docker-socket-proxy
2026-02-04 21:24:46 -05:00
Lucas Berger 884fefaab5 docs(10.1-02): complete batch UI extraction plan
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
2026-02-04 21:21:32 -05:00
Lucas Berger 8b9af171b6 feat(10.1-02): extract batch UI to sub-workflow
- Updated main workflow to call n8n-batch-ui.json sub-workflow
- Main workflow reduced from 192 to 179 nodes (-13 nodes)
- Removed 22 batch UI nodes now handled by sub-workflow:
  - Fetch/Build/Rebuild Batch Select Keyboard nodes
  - Handle Batch Toggle/Clear/Exec/Nav nodes
  - Answer and Edit keyboard nodes
- Added 9 new nodes for sub-workflow integration:
  - Prepare Batch UI Input
  - Execute Batch UI (TODO_DEPLOY_BATCH_UI_WORKFLOW placeholder)
  - Route Batch UI Result with action routing
  - Telegram response handlers for keyboard/confirm/cancel/limit
- Batch execution loop remains in main workflow (orchestration)
- Created backup file for rollback capability

Part of batch UI extraction (Task 2-3/3)
2026-02-04 21:19:57 -05:00
Lucas Berger 07a62d13f1 feat(10.1-02): create batch UI sub-workflow
- Created n8n-batch-ui.json with 16 nodes
- Handles batch selection UI: mode, toggle, nav, clear, cancel, exec actions
- Returns structured data for main workflow to send Telegram responses
- Entry point: Execute Workflow Trigger with input contract
- Uses existing Docker API pattern for container listing

Part of batch UI extraction (Task 1/3)
2026-02-04 21:16:13 -05:00
Lucas Berger cd7c177553 docs(10.1-01): complete foundation and domain analysis plan
Tasks completed: 3/3
- Rename sub-workflows to shorter pattern
- Analyze main workflow domain boundaries
- User approval on extraction boundaries

SUMMARY: .planning/phases/10.1-aggressive-workflow-modularization/10.1-01-SUMMARY.md
2026-02-04 21:10:07 -05:00
Lucas Berger fba90a6cc4 docs(10.1-01): analyze main workflow domain boundaries
Domain analysis of 192-node main workflow:
- Batch UI/Orchestration: 48 nodes (HIGH extraction value)
- Container List/Menu: 17 nodes (HIGH extraction feasibility)
- Confirmation Dialogs: 30 nodes (MEDIUM extraction feasibility)
- Matching/Disambiguation: 15 nodes (optional extraction)
- Telegram Responses: 58 nodes (LOCKED to remain in main)

Key finding: Target of 50-80 nodes not achievable due to locked
Telegram response pattern. Realistic target: 115-125 nodes.

Recommended extraction order:
- Wave 2: Batch UI + Container List
- Wave 3: Confirmation + Matching (optional)
2026-02-04 20:29:21 -05:00
Lucas Berger ff532aa99e refactor(10.1-01): rename sub-workflows to shorter pattern
- n8n-container-update.json -> n8n-update.json
- n8n-container-actions.json -> n8n-actions.json
- n8n-container-logs.json -> n8n-logs.json

Workflow IDs remain unchanged (n8n assigns on import).
Main workflow Execute Workflow nodes reference by ID, not filename.
2026-02-04 20:26:34 -05:00
Lucas Berger 25dd3ab2d2 docs(10.1): create phase plan
Phase 10.1: Aggressive Workflow Modularization
- 5 plan(s) in 3 wave(s)
- Wave 1: Foundation (rename files, analyze boundaries, user approval)
- Wave 2: 3 parallel extractions (batch-ui, status, confirmation)
- Wave 3: Integration verification and UAT
- Ready for execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 20:20:29 -05:00
Lucas Berger f071a949b1 docs(10.1): research phase domain
Phase 10.1: Aggressive Workflow Modularization
- Standard stack identified (Execute Workflow nodes, sub-workflow patterns)
- Architecture patterns documented (input contracts, error handling, routing)
- Pitfalls catalogued (memory issues, data references, error gaps, circular deps)
- Analyzed existing workflows (192 nodes main, 3 sub-workflows)
- Validated patterns against n8n docs and community best practices
- Confidence: HIGH (grounded in existing implementations + locked user decisions)
2026-02-04 20:14:22 -05:00
Lucas Berger 8e372dd8ed wip: 10.1-aggressive-workflow-modularization paused at context gathered
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 17:01:32 -05:00
Lucas Berger 9285f3e011 docs(10.1): capture phase context
Phase 10.1: Aggressive Workflow Modularization
- Implementation decisions documented
- Phase boundary established
- Fixed misnamed phase directories (10.1/10.2)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 17:00:37 -05:00
Lucas Berger a8c9ab69d6 fix(batch): edit message in place instead of delete+send
- Skip Delete Batch Select Message node for batch start
- Use editMessageText instead of sendMessage
- Batch start now smoothly transitions like batch stop

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:41:07 -05:00
Lucas Berger 23f60ff043 fix(batch): edit confirmation message instead of sending new one
Changed batch start to editMessageText so the confirmation message
gets updated with progress/results instead of leaving it hanging
and sending a separate progress message.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:30:42 -05:00
Lucas Berger d043e11bd4 fix(actions): fix paired item reference in Format Result nodes
Changed from $('When executed by another workflow') to $('Route Action')
to avoid paired item reference errors when data flows through the
Resolve Container ID path.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:26:31 -05:00
Lucas Berger 4ea0824c40 chore: add project-level Claude instructions
Includes n8n API integration docs, workflow IDs, push commands,
and technical patterns learned during development.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:22:41 -05:00
Lucas Berger adbd7bd87d fix(batch): resolve container IDs in sub-workflows
When batch operations are triggered via keyboard callbacks, the main
workflow only passes container names (not IDs). The sub-workflows now:
- Check if containerId is empty
- If empty, query Docker API to resolve name → ID
- Then proceed with the action

This fixes batch start/stop/restart/update operations failing with
404 "page not found" errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:19:33 -05:00
Lucas Berger f7859fc3c4 docs(phase-10): complete workflow modularization phase
All 7 plans executed and verified:
- 3 sub-workflows (Update, Actions, Logs)
- UAT gaps closed (race conditions, data chains, fuzzy matching)
- Main workflow: 209 → 192 nodes (-8%)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 16:05:06 -05:00
Lucas Berger b156fe48cf docs(10-07): complete UAT gap closure plan
Tasks completed: 5/5
- Fix text update race condition (remove parallel message)
- Fix batch update data chain (Build Progress Message reference)
- Fix batch action data chain (Build Progress Message reference)
- Add fuzzy matching to logs and fix chatId reference
- Add timestamp to logs refresh for message not modified error

SUMMARY: .planning/phases/10-workflow-modularization/10-07-SUMMARY.md
2026-02-04 16:01:49 -05:00
Lucas Berger 1869cab358 fix(10-07): add timestamp to logs refresh to prevent message not modified error
- Format Inline Logs Result now adds timestamp to message
- Shows 'Updated: HH:MM:SS' at bottom of logs display
- Ensures Telegram API always accepts refresh (content always different)
2026-02-04 16:00:30 -05:00
Lucas Berger 77c3d6543d fix(10-07): add fuzzy matching to logs and fix chatId reference
- Send Logs Response now uses Prepare Text Logs Input for chatId
- Container logs sub-workflow uses .includes() for fuzzy matching
- Multiple match handling added with helpful error message
2026-02-04 16:00:07 -05:00
Lucas Berger 28f4c59d3f fix(10-07): fix batch action data chain reference
- Prepare Batch Action Input now uses Build Progress Message reference
- Fixes 'Cannot read properties of undefined' error for batch actions
- Data chain: Build Progress Message -> Edit Progress Message -> Prepare Batch Action Input
2026-02-04 15:59:33 -05:00
Lucas Berger 63a0019ccf fix(10-07): fix batch update data chain reference
- Prepare Batch Update Input now uses Build Progress Message reference
- Fixes 'Cannot read properties of undefined' error
- Data chain: Build Progress Message -> Edit Progress Message -> Prepare Batch Update Input
2026-02-04 15:59:05 -05:00
Lucas Berger 9d38bf9f51 fix(10-07): remove text update race condition
- Remove parallel Send Text Update Started connection
- Text updates now only send result via sub-workflow
- Fixes duplicate message issue (Updating... + already up to date)
2026-02-04 15:58:47 -05:00
Lucas Berger 5a6b6e3e85 docs(10): create UAT gap closure plan 10-07
Phase 10 UAT revealed 5 gaps:
- Text update race condition (parallel message send)
- Batch update/action data chain broken ($json vs Build Progress Message)
- Logs fuzzy matching missing
- Logs refresh "message not modified" error

10-07-PLAN.md addresses all gaps in 5 tasks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:54:02 -05:00
Lucas Berger ff675b7e19 test(phase-10): complete UAT - 4 passed, 5 issues
Issues found:
1. Text update sends duplicate messages (sub-workflow + main)
2. Batch update broken - data chain broken after Edit Progress Message
3. Batch actions broken - same data chain issue
4. Logs text command - no fuzzy matching, chatId not preserved
5. Logs refresh - doesn't handle 'message not modified' error

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:50:20 -05:00
Lucas Berger 1d55988aff docs(phase-10): complete workflow modularization phase
Phase 10 achievements:
- 3 sub-workflows: Update, Actions, Logs (all deployed)
- Main workflow: 209 → 192 nodes (-8%)
- Consolidated all container operations
- Removed old batch inline path
- Modernized callback formats

Deferred to Phase 10.1: Aggressive modularization (50-80 node target)
Added Phase 10.2: Better Logging & Log Management

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:10:19 -05:00
Lucas Berger 57ca18f4d4 refactor(10-06): remove old batch inline path and modernize callbacks
- Update Build Batch Keyboard to use bexec: format instead of legacy JSON
- Update Build Suggestion Keyboard to use action: format instead of legacy JSON
- Remove 7 nodes from old batch inline execution path:
  - Build Batch Commands
  - Prepare Batch Execution
  - Execute Batch Action
  - Parse Batch Result
  - Format Batch Result
  - Send Batch Result
  - Answer Batch Query

Node count: 199 -> 192 (-7 nodes)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:07:05 -05:00
Lucas Berger 9799de9418 fix(10-06): deploy logs sub-workflow and wire to main
- Deploy Container Logs sub-workflow to n8n (ID: oE7aO2GhbksXDEIw)
- Replace TODO_DEPLOY_LOGS_WORKFLOW with actual workflow ID
- Update n8n-container-logs.json with deployed ID
- Redeploy all workflows to n8n

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 15:04:14 -05:00
Lucas Berger e160b3e1cd docs(10-06): complete remediation plan
Tasks completed: 4/5 (1 skipped - path still needed)
- Fix batch actions routing to use sub-workflow
- Wire logs sub-workflow (deployment documented)
- Remove Python helper scripts (6 files, 1468 lines)
- Task 3 skipped: old inline path handles legacy callbacks

SUMMARY: .planning/phases/10-workflow-modularization/10-06-SUMMARY.md
2026-02-04 14:55:46 -05:00
Lucas Berger 2bf607ea01 chore(10-06): remove Python helper scripts
- Delete refactor_workflow.py
- Delete task1_batch_update.py
- Delete task2_batch_actions.py
- Delete task3_logs_subworkflow.py
- Delete task3_update_main.py
- Delete task4_cleanup.py

These were development-time helpers for JSON manipulation, not runtime code.
2026-02-04 14:54:30 -05:00
Lucas Berger 1d420bd7dd fix(10-06): update logs sub-workflow placeholder
- Replace PLACEHOLDER_LOGS_ID with TODO_DEPLOY_LOGS_WORKFLOW
- Applies to Execute Text Logs and Execute Inline Logs nodes
- Clear marker indicates n8n-container-logs.json deployment required
- User must replace TODO with actual workflow ID after n8n import
2026-02-04 14:53:13 -05:00
Lucas Berger 807583dfff fix(10-06): fix batch actions routing to use sub-workflow
- Add exclusion condition to Route Callback rule 4 (isBatch)
- Rule now requires isBatch=true AND isBatchExec!=true
- Ensures batch execution callbacks route to Handle Batch Exec (output 17)
- Prevents bypass to old Build Batch Commands inline path (output 4)
2026-02-04 14:52:44 -05:00
Lucas Berger ed0e0e7ba2 docs(10-05): complete modularization plan
Tasks completed: 4/4
- Wire batch update to Container Update sub-workflow
- Wire batch actions to Container Actions sub-workflow
- Extract logs flow to Container Logs sub-workflow
- Clean up and verify workflow

Results:
- Main workflow: 209 → 199 nodes (-10, -4.8%)
- Created n8n-container-logs.json sub-workflow (9 nodes)
- All batch operations use sub-workflows (eliminated duplicate logic)
- 9 sub-workflow calls total (3 for Update, 4 for Actions, 2 for Logs)

Phase 10 now COMPLETE.

SUMMARY: .planning/phases/10-workflow-modularization/10-05-SUMMARY.md
2026-02-04 14:00:33 -05:00
Lucas Berger 186f11362e chore(10-05): verify and document workflow refactoring
- Run cleanup and verification script
- No orphaned nodes found
- Workflow structure validated
- Final node count: 199 (reduced from 209, -4.8%)
- Add comprehensive deployment guide

Node composition:
- 79 code nodes
- 50 httpRequest nodes
- 27 telegram nodes
- 14 if nodes
- 10 switch nodes
- 9 executeCommand nodes
- 9 executeWorkflow nodes (sub-workflow calls)
- 1 telegramTrigger node

Note: Node count (199) is above target range (120-150) but achieves
primary goals of eliminating duplicate logic. Further optimization
possible (~40-45 nodes) by consolidating batch UI and confirmation flows.

Deployment requires importing n8n-container-logs.json and updating
the workflow ID in main workflow Execute Text/Inline Logs nodes.
2026-02-04 13:58:48 -05:00
Lucas Berger 6471dcecd6 feat(10-05): extract logs flow to Container Logs sub-workflow
Created n8n-container-logs.json:
- Execute Workflow Trigger entry point
- Parse and validate input (containerId/Name, lineCount, chatId, messageId)
- Query Docker to find container by name if needed
- Execute docker logs command
- Format output for Telegram (HTML escape, truncate, add header)
- Return success/message/containerName/lineCount

Updated main workflow:
- Add Prepare Text Logs Input (text command path)
- Add Execute Text Logs sub-workflow node
- Add Prepare Inline Logs Input (inline keyboard path)
- Add Execute Inline Logs sub-workflow node
- Add Format Inline Logs Result (adds keyboard)
- Remove 14 obsolete inline logs nodes
- Node count: 208 -> 199 (-9)

Sub-workflow has placeholder ID - will be updated after n8n import in Task 4.
2026-02-04 13:56:51 -05:00
Lucas Berger 89e459f96c feat(10-05): wire batch actions to Container Actions sub-workflow
- Add Prepare Batch Action Input node to format sub-workflow input
- Add Execute Batch Action Sub-workflow node calling Container Actions
- Add Handle Batch Action Result Sub node to process results
- Remove 7 obsolete inline action nodes:
  * Build Batch Action Command
  * Execute Batch Container Action
  * Check Batch Action Result
  * Needs Action Call
  * Execute Batch Action 2
  * Parse Batch Action 2
  * Handle Action Result
- Node count: 212 -> 208 (-4 net)

This eliminates duplicate action execution logic between single and batch paths.
2026-02-04 13:54:51 -05:00
Lucas Berger e4a7098e0d feat(10-05): wire batch update to Container Update sub-workflow
- Add Prepare Batch Update Input node to format sub-workflow input
- Add Execute Batch Update node calling Container Update sub-workflow
- Add Handle Batch Update Result node to process results
- Connect update path (output 0) in Route Batch Loop Action
- Node count: 209 -> 212 (+3)

This completes the batch update integration with the modular sub-workflow,
eliminating the need for duplicate update logic in the main workflow.
2026-02-04 13:54:18 -05:00
Lucas Berger c7c23b77c3 docs(10): checkpoint - waves 1-3 complete, wave 4 pending
Completed:
- 10-01: Orphan cleanup (2 nodes removed)
- 10-02: Container Update sub-workflow (31 nodes)
- 10-03: Container Actions sub-workflow (8 nodes)
- 10-04: Integration verified with user

Pending:
- 10-05: Wire batch ops to sub-workflows, extract logs

Key fixes applied:
- n8n typeVersion 1.2 requires __rl resource locator format
- Docker 204 success detection via empty response check

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:46:48 -05:00
Lucas Berger b83f76b27b 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 <noreply@anthropic.com>
2026-02-04 13:43:09 -05:00
Lucas Berger 6ef2736cff fix(10-03): fix success detection for container actions
Docker API returns 204 No Content on success (empty response body).
Changed from checking statusCode (not available in n8n httpRequest)
to checking for absence of error/message in response body.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:37:03 -05:00
Lucas Berger 5337e17f21 fix(10): use resource locator format for Execute Workflow nodes
n8n typeVersion 1.2 requires workflowId as resource locator object:
  { "__rl": true, "mode": "list", "value": "<id>" }
not a plain string. This was causing "workflow not found" errors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:33:51 -05:00
Lucas Berger fd31902a82 fix(10-03): update container actions workflow ID
Recreated Container Actions sub-workflow via API to fix
"workflow not found" error. New ID: fYSZS5PkH0VSEaT5

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:28:03 -05:00
Lucas Berger 40a05fe390 fix(10-02): hardcode sub-workflow IDs for self-hosted n8n
Self-hosted n8n doesn't support environment variables.
Replace $env references with actual workflow IDs:
- CONTAINER_UPDATE_WORKFLOW_ID → 7AvTzLtKXM2hZTio92_mC
- CONTAINER_ACTIONS_WORKFLOW_ID → xRRDIk19Gq57WECjtSy_j

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 13:20:00 -05:00
Lucas Berger d3c1525f53 docs(10-03): complete container actions sub-workflow plan
Tasks completed: 3/3
- Task 1: Create container-actions sub-workflow
- Task 2: Wire main workflow to use sub-workflow
- Task 3: Deploy verification (local checks passed)

SUMMARY: .planning/phases/10-workflow-modularization/10-03-SUMMARY.md

Note: Full deployment verification requires n8n access
User setup: Set CONTAINER_ACTIONS_WORKFLOW_ID env var in n8n
2026-02-04 13:12:36 -05:00
Lucas Berger d07932f69f feat(10-03): wire main workflow to use container-actions sub-workflow
- Added 9 nodes for sub-workflow integration
- Text path: Check Match Count -> Prepare Text Action Input -> Execute Container Action
- Inline path: Get Container For Action -> Prepare Inline Action Input -> Execute Inline Action
- Confirmed stop: Get Container For Stop -> Prepare Confirmed Stop Input -> Execute Confirmed Stop Action
- Confirmation dialogs remain in main workflow (stop, batch stop)
- Uses CONTAINER_ACTIONS_WORKFLOW_ID env var for sub-workflow reference
2026-02-04 13:10:14 -05:00
Lucas Berger d0b03b7159 feat(10-02): wire main workflow to use container-update sub-workflow
- Removed 54 duplicate update nodes from text and callback paths
- Added Execute Sub-workflow nodes for both update entry points
- Text path: Check Update Match Count -> Prepare Text Update Input -> Execute Text Update
- Callback path: Route Confirm Action -> Prepare Callback Update Input -> Execute Callback Update
- Workflow reduced from 246 to 200 nodes (-19%)
- Line count reduced from ~8485 to 7209 (-15%)

DEBT-03 (duplicated update flow) resolved - update logic now in one place
2026-02-04 13:08:37 -05:00
Lucas Berger 8c8ebee370 feat(10-02): create container-update sub-workflow
- New sub-workflow with 31 nodes encapsulating entire update flow
- Input contract: containerId, containerName, chatId, messageId, responseMode
- Output contract: success, updated, message, oldDigest, newDigest
- Handles both text and inline response modes
- Preserves :latest tag protection and old image cleanup
2026-02-04 13:07:13 -05:00
Lucas Berger 35705a7707 feat(10-03): create container actions sub-workflow
- Add n8n-container-actions.json with executeWorkflowTrigger
- Input contract: containerId, containerName, action, chatId, messageId, responseMode
- Routes to start/stop/restart via Switch node
- Returns: success, message, action, containerName for caller to handle response
2026-02-04 13:06:38 -05:00
Lucas Berger 99cdb95482 docs(10-01): complete orphan node cleanup plan
Tasks completed: 2/2
- Identified 2 orphan nodes via BFS from Telegram Trigger
- Removed orphan nodes, deployed, verified working

SUMMARY: .planning/phases/10-workflow-modularization/10-01-SUMMARY.md
2026-02-04 13:03:50 -05:00