refactor: split validateDefinition into focused validators #448
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#448
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:2342-2504—validateDefinitionis 163 lines in one body.It validates pools, limits, workspace, triggers, per-node type/agent/repeat/resource/lease rules, and runs a Kahn topological sort for cycle detection:
Why it matters
Validation is the workflow API's entire input trust boundary. A 163-line body with mixed concerns makes it hard to see which inputs are unchecked, and hard to add a rule without re-reading everything. The graph walk in particular is independently testable logic buried at the bottom.
Suggested fix
The split precedent already exists —
validateTrigger,validateLease,validateSecrets,validateCommandNodeare already separate. Extract to match:validatePools(definition) error— pools, limits, workspace.validateNodes(definition) error— per-node type/agent/repeat/resource/lease checks.validateGraph(definition) error— dependency existence + Kahn cycle detection.Acceptance criteria
validateDefinitionbecomes a short sequence ofvalidate*calls.Effort: M.