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:
2026-04-12 13:05:05 +02:00
parent cb96e85b69
commit c3dfc9315f
21 changed files with 1569 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
---
name: cron_match
kind: function
lang: go
domain: core
version: "1.0.0"
purity: pure
signature: "func CronMatch(sched CronSchedule, t time.Time) bool"
description: "Verifica si un instante de tiempo coincide con un cron schedule. Compara los 5 campos (minuto, hora, dia del mes, mes, dia de la semana) y retorna true si todos coinciden."
tags: [cron, scheduling, matching, time, pure]
uses_functions: []
uses_types: [cron_schedule_go_core]
returns: []
returns_optional: false
error_type: ""
imports: [time]
params:
- name: sched
desc: "CronSchedule con listas de valores validos por campo (resultado de ParseCronExpr)"
- name: t
desc: "instante de tiempo a verificar contra el schedule"
output: "true si t coincide con todos los campos del cron schedule"
tested: true
tests:
- "9:00 AM coincide con 0 9 * * *"
- "9:15 AM NO coincide con 0 9 * * *"
- "lunes a las 9 coincide con 0 9 * * 1"
- "domingo a las 9 NO coincide con 0 9 * * 1"
- "wildcard * coincide con cualquier valor"
- "specific month"
test_file_path: "functions/core/cron_match_test.go"
file_path: "functions/core/cron_match.go"
---
## Ejemplo
```go
sched, _ := ParseCronExpr("0 9 * * *")
t := time.Date(2026, 4, 11, 9, 0, 0, 0, time.UTC)
CronMatch(sched, t) // true
t2 := time.Date(2026, 4, 11, 10, 0, 0, 0, time.UTC)
CronMatch(sched, t2) // false
```
## Notas
Funcion pura. Usa AND semantics para day_of_month y day_of_week (ambos deben coincidir), igual que NextCronTime en el mismo paquete.
Reutiliza el helper intIn definido en next_cron_time.go (mismo paquete core).