feat: add DAG core functions — parse, validate, topo sort, resolve env, cron match (0007a, 0007d)
Pure functions for parsing dagu-compatible YAML, validating DAG structure, topological sorting with parallel levels (Kahn's algorithm), and env variable resolution. Also adds cron_match for schedule matching. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
package core
|
||||
|
||||
// DagContinueOn controls whether a step continues on failure/skip.
|
||||
type DagContinueOn struct {
|
||||
Failure bool
|
||||
Skipped bool
|
||||
}
|
||||
|
||||
// DagRetryPolicy configures automatic retries for a step.
|
||||
type DagRetryPolicy struct {
|
||||
Limit int
|
||||
IntervalSec int
|
||||
}
|
||||
|
||||
// DagStep represents a single step in a DAG workflow.
|
||||
type DagStep struct {
|
||||
Name string
|
||||
ID string
|
||||
Description string
|
||||
Command string
|
||||
Script string
|
||||
Args []string
|
||||
Shell string
|
||||
Dir string
|
||||
Depends []string
|
||||
Env map[string]string
|
||||
ContinueOn DagContinueOn
|
||||
RetryPolicy DagRetryPolicy
|
||||
TimeoutSec int
|
||||
Output string
|
||||
Tags []string
|
||||
}
|
||||
|
||||
// DagHandlers contains lifecycle handler steps.
|
||||
type DagHandlers struct {
|
||||
Init []DagStep
|
||||
Success []DagStep
|
||||
Failure []DagStep
|
||||
Exit []DagStep
|
||||
}
|
||||
|
||||
// DagDefinition is a complete DAG workflow parsed from YAML.
|
||||
type DagDefinition struct {
|
||||
Name string
|
||||
Description string
|
||||
Group string
|
||||
Type string // "graph" or "" (chain/sequential)
|
||||
WorkingDir string
|
||||
Shell string
|
||||
Env map[string]string
|
||||
Schedule []string
|
||||
Steps []DagStep
|
||||
HandlerOn DagHandlers
|
||||
Tags []string
|
||||
TimeoutSec int
|
||||
FilePath string
|
||||
}
|
||||
|
||||
// DagValidationResult contains validation output.
|
||||
type DagValidationResult struct {
|
||||
Valid bool
|
||||
Errors []string
|
||||
Warnings []string
|
||||
Levels [][]string // topological levels (step names/IDs)
|
||||
}
|
||||
Reference in New Issue
Block a user