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
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.