feat: add loop_wait_sec to repeat the steps of a service DAG in one run
Summary
Closes #3259.
Adds loop_wait_sec and loop_on_failure: with an enabled restart_policy, a run repeats its steps in the same run, as in a while true loop, and a run ends only when something interrupts it.
Stacked on #3261. Review only the last two commits.
restart_policy: always
restart_wait_sec: 5
loop_wait_sec: 5
loop_on_failure: restart # or continue
steps:
- run: ./fetch.sh
Changes
-
Spec 080 (loop section, validation errors, examples), JSON schema, conformance fixtures.
-
ir.DAG.LoopWaitandLoopOnFailure; validation:loop_wait_secis not negative and needsrestart_policyalways or unless-stopped;loop_on_failureneeds a positiveloop_wait_sec; neither is allowed in the base configuration. -
Agent:
runCyclesruns the steps again from a fresh plan after the wait. Handlers andtimeout_secapply to each cycle. A stop during the wait ends the run as aborted. A failed cycle ends the run with its status (restart, the default), or the loop goes on (continue). -
The status carries
cycleandfailedCycles. When a cycle starts, the logs of the previous cycle are removed, except those of the latest failed cycle. The status file is compacted at each cycle end. -
API:
loopWaitSec,loopOnFailureon DAG and DAG details;cycle,failedCycleson DAG-run details. UI: the cycle in the run details of the workflow bar and in the status card, and the loop in the restart label. -
A timeout (
timeout_sec) is a failed cycle; the spec says so. -
A DAG that sets
loop_wait_secwithworker_selectorloads with a warning: the coordinator appends the status of a run on a worker, and nothing compacts it between cycles. The spec lists what a looping run stores and what bounds it. -
A cycle that goes well adds no line to the log of the run (debug level); that log is not rotated.
-
The Spec tab shows the loop in the restart label. The DAG list does not, because its index does not keep the loop.
Related Issues
Closes #3259
Checklist
- Code follows the project style guidelines
- Self-review of the code has been performed
- Tests have been added or updated as needed
- Documentation has been updated as needed
- Changes have been tested locally
Tests: go test -race ./internal/intg -run TestLoopWait (six tests: one run for several cycles, failed cycle ends the run, restart keeps looping while cycles succeed, continue, log removal, status compaction), internal/ir, internal/spec, internal/runtime/agent, internal/persis, internal/service/frontend, make conformance, pnpm typecheck and pnpm test.