refactor: split workflow dispatchLocked and stop abandoning ready nodes on error #446
Labels
No labels
backend
bug
chore
duplication
effort:complex
effort:medium
effort:trivial
enhancement
follow-up
frontend
fullstack
priority:high
ready-for-agent
refactor
security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dries/ocman#446
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Code-quality audit (P2).
internal/workflows/service.go:1902-2085—dispatchLockedis 184 lines at 4 levels of nesting.The problem
An unbounded
for {}wraps a node loop that inlines: claim, shard provisioning, prompt interpolation, item substitution, schema-instruction append, agent start, agent inspect, schema-correction retry, and completion.This is a latent bug, not only a readability issue. Several
returns sit inside the node loop, so a failure on one node silently abandons every remaining ready node in that pass:Same shape for the
SetWorkflowAgentSessionStateerror returns below it. A transient inspect failure on node A stalls node B, C, ... until the next dispatch tick, and if the error is sticky the run wedges.Suggested fix
startAgentAttempt,inspectAgentAttempt,requestSchemaCorrection.for {}with an explicit progress/iteration guard.Acceptance criteria
dispatchLockedis under ~60 lines and at most 2 nesting levels.Inspectfails for the first — assert the second still starts. Must fail on currentmainbefore the fix.Effort: L.
Validated against main @
2d661364: partially fixed — the named wedge is gone. Inspect failures no longer return from the node loop: recordInspectFailure + continue, marking the attempt unknown only after the failure proves persistent (service.go:2233-2251; the comment there documents the old stall). Launch failures get bounded retries too (:2190-2211). Still true: state.db store-error returns inside the loop (ClaimWorkflowAgentAttempt :2152, AttachWorkflowAgentSession :2219, SetWorkflowAgentSessionState :2259/:2287, CompleteWorkflowAgentNode :2298) abandon the rest of the pass — but the periodic tick retries, and a sticky state.db failure breaks the engine regardless. Rescope: refactor + per-node error collection, no longer a run-wedging bug.Closing as obsolete: the Workflows feature has been retired.
internal/workflowsno longer exists — DAG-based workflows were replaced by project-bound Routines (internal/routines, see #576 and docs/features/routines.md). The code this refactor targeted is gone, so there is nothing left to split or fix here.