Synced from Hive. This page is pulled from hivecommons/hive@v5 during the docs build. Edit the canonical source in the Hive repository.

DAG workflows

A DAG workflow (kind: TaskWorkflow) is a directed acyclic graph of agent steps that hive runs itself. Each step is a prompt to one of the hive’s agents, or to any free member of an agent pool. depends_on orders the steps: a step starts only when every step it depends on has succeeded, steps with no path between them run in parallel, and hive retries failed attempts, times them out and records each attempt’s agent, result and failure reason. The agent reports each step with hive-step-done, so completion is a structured report, not a guess.

DAG workflows are one of three ways to bring a DAG into hive, side by side with importing GitHub Actions workflows and importing Tekton pipelines. For how the three compare, and how they relate to lifecycle workflow models, see Workflows in hive.

When to use a DAG workflow

DAG workflowGitHub Actions importTekton import
You start fromA YAML or JSON spec you write.github/workflows/*.yml and *.yaml filesTekton YAML files or a live cluster
A node isAn agent step: a prompt to an agent or poolA jobA task
Edges come fromdepends_onneedsrunAfter and result references
Who runs the nodesHive, on its own agentsGitHub ActionsTekton
What hive addsScheduling, retries, timeouts, gating, run historyThe pipeline drawn inside a lifecycle model, bound to its statesThe same, for Tekton
Can become a DAG workflowIt is oneYes, as a disabled draft (how)Yes, as a disabled draft (how)

Author a DAG workflow when the work is agent work that hive should drive: several prompts that must run in a set order, some in parallel, with a retry when one fails and a gate before the next stage. Import GitHub Actions or Tekton when the pipeline already exists in that system and you want hive to know about it; if you then want hive to run the same shape on agents, the import’s task workflow draft gives you the steps and edges, and you write the prompts.

The task workflows guide walks through one complete setup, a regression pipeline on a pool of three agents. This page is the reference for the spec and the runner. The design record is Task workflows design.

Prerequisites

  • Task workflows turned on. They are off by default: set workflow.tasks.enabled: true (env HIVE_WORKFLOW_TASKS_ENABLED), or use Enable task workflows under Settings → Workflows → Task workflows. Turning it on or off takes a restart. While it is off, every /api/task-workflows route except /api/task-workflows/settings answers 404, and no runner starts.
  • Owner role to save, enable, delete, approve steps and manage run-trigger tokens. A merger can start a run on the workflow’s defaults, cancel and re-run; every authenticated user can read workflows and runs.
  • Configured agents for every step. A step names an existing agent, or a pool of existing agents; a workflow does not create agents or choose backends. Dedicated agents with their governor cadence paused are recommended, so ordinary work does not compete with steps.
  • Distinct per-agent UIDs. Agents report with hive-step-done, which drops a request file that hive attributes to the agent whose UID owns it. Without per-agent UIDs the relay refuses every report, fail closed.

Author from the dashboard

  1. Open Settings → Workflows → Task workflows.
  2. Write or paste the spec in the YAML editor and choose Validate. Diagnostics list every problem with its code and the field it concerns.
  3. Save it. A workflow with errors can be saved only disabled; enable it once it validates.
  4. Choose Run now and follow the run on its run page. An owner fills in the params (a blank one takes its default); a merger starts the run on the defaults.

Author with the API

POST /api/task-workflows/validate and PUT /api/task-workflows/{name} take the same body:

FieldTypeMeaning
yamlstringThe spec as YAML or JSON text
workflowobjectThe spec as a JSON object, instead of yaml
enabledbooleanSave only: whether the workflow may run. Refused with 422 and the diagnostics when the spec has errors

Validate, then save enabled (the examples use the dashboard token, which carries the owner role on a self-hosted hive):

yaml=$(cat release-readiness.yaml)
curl --fail-with-body -X POST https://hive.example/api/task-workflows/validate \
  -H "Authorization: Bearer $HIVE_TOKEN" -H 'Content-Type: application/json' \
  --data "$(jq -n --arg y "$yaml" '{yaml: $y}')"
curl --fail-with-body -X PUT https://hive.example/api/task-workflows/release-readiness \
  -H "Authorization: Bearer $HIVE_TOKEN" -H 'Content-Type: application/json' \
  --data "$(jq -n --arg y "$yaml" '{yaml: $y, enabled: true}')"

Validate answers ok, diagnostics (code, severity, subject, detail) and the parsed workflow. Save answers the stored definition (with its revision, hash, saved_by and saved_at) and the diagnostics; each save is a new revision and is audited as task_workflow_saved. metadata.name must match the path. DELETE /api/task-workflows/{name} removes a workflow, revokes its run-trigger tokens and deletes its notification secret; it is refused with 409 while the workflow has an active run.

The spec

apiVersion: workflow.hivecommons.dev/v1alpha1
kind: TaskWorkflow
metadata:
  name: my-workflow
  description: What this workflow is for
spec:
  params: []        # run inputs
  pools: {}         # named agent pools
  concurrency: 4    # steps running at once in one run
  timeout: 6h       # whole-run timeout, optional
  schedule: {}      # cron trigger, optional
  notify: {}        # outbound notification, optional
  steps: []         # the DAG

YAML and JSON are both accepted; field names are exactly the ones below, and an unknown field is a parse error, so a typo such as dependsOn is caught instead of silently dropping an edge.

Top-level fields

FieldMeaningDefault
apiVersionworkflow.hivecommons.dev/v1alpha1required
kindTaskWorkflowrequired
metadata.nameLower-case letters, digits and hyphens, starting with a letter or digit, at most 63 characters. hooks, import, settings and validate are reservedrequired
metadata.descriptionFree text, at most 1,000 charactersnone
metadata.labelsString map, kept with the workflownone
spec.paramsRun inputs (below)none
spec.poolsPool name → list of agent namesnone
spec.concurrencySteps of one run that may run at once, 1 to 504
spec.timeoutWhole-run timeout, a Go duration such as 6h, at most 7 daysnone
spec.schedulecron (five fields), tz (required) and paramsnone
spec.notifyurl and events (run, step; empty means both)none
spec.stepsThe steps, at least onerequired

Steps

FieldMeaningDefault
idUnique step id: lower-case letters, digits and hyphens, at most 63 charactersrequired
agentOne agent by nameset exactly one of agent and pool
poolA pool name from spec.pools; any free member may run the stepset exactly one of agent and pool
promptThe step’s instructions, a template (below), at most 8,000 charactersrequired
depends_onStep ids that must all have succeeded before this step startsnone
retry.max_attemptsTotal attempts including the first, 1 to 101
retry.backoffWait before the second attempt (Go duration)1m
retry.factorMultiplier applied to the wait after each further attempt, 1 to 102
retry.max_backoffCeiling on the wait30m
timeoutPer-attempt timeout, from the moment the kick is delivered, 1m to 24hworkflow.tasks.default_step_timeout (60m)
on_failurestop or continue, applied once the step has used all its attemptsstop
approvalrequired holds the step for an owner before it is kickednone

The wait before attempt n is backoff × factor^(n−2), capped at max_backoff: with the defaults, 1 minute before attempt 2, 2 minutes before attempt 3, 4 before attempt 4.

Dependencies: fan-out and fan-in

The graph is the depends_on lists, nothing else. There is no separate stage or parallel block:

  • Sequence. b lists a in depends_on; b starts after a succeeds.
  • Fan-out. Several steps list the same step; once it succeeds they are all ready at once and run in parallel, up to the concurrency caps and the free agents.
  • Fan-in. One step lists several; it waits until all of them have succeeded. If any of them fails, is skipped or is cancelled, the fan-in step is skipped.
  • Independent branches. Steps with no path between them never wait for each other.
steps:
  - { id: build, agent: builder, prompt: "..." }
  - { id: test-unit, pool: testers, depends_on: [build], prompt: "..." }  # fan-out
  - { id: test-e2e,  pool: testers, depends_on: [build], prompt: "..." }  # fan-out
  - { id: report, agent: builder, depends_on: [test-unit, test-e2e], prompt: "..." }  # fan-in

There is no “run on failure” edge: depends_on always waits for success. A step that must run whatever happened upstream cannot be expressed as a dependant of the steps it reports on.

Params and prompt templates

Params are the run’s inputs:

FieldMeaning
nameStarts with a letter or underscore; letters, digits, _ and -; at most 63 characters
descriptionShown as a hint on the dashboard’s run form
requiredA run must supply it, unless it has a default
defaultUsed when a run does not supply the param

At most 32 params. When a run starts, unknown params are refused, a required param with no value and no default is refused, and defaults fill the rest. Each value is at most 4 KiB of valid UTF-8 with no control or format characters other than newline and tab.

A prompt may reference:

ReferenceValue
{{params.<name>}}The run’s value for a declared param
{{steps.<id>.result}}The reported result of a step this step depends on, directly or transitively
{{run.id}}, {{step.id}}, {{step.attempt}}, {{workflow.name}}Identity of the current attempt

Templates are plain substitution: no conditionals, loops or functions, and values are inserted verbatim. A reference to an undeclared param, to a step that is not an ancestor (its result could not exist yet) or to any other name is a validation error.

Hive prepends a fixed header to the rendered prompt that names the workflow, run, step and attempt and gives the agent the exact hive-step-done commands to report success or failure. The header plus the rendered prompt must fit the kick limit of 10,000 bytes; a prompt that does not fit fails the step with prompt-too-long instead of being truncated.

Params, and results that earlier steps reported, are untrusted input to the prompts they land in, particularly when a run-trigger token holder supplies the params. Decide in the spec where they appear, and never put secrets in params, prompts or results.

Validation

Validation runs in the editor, on POST /api/task-workflows/validate, on save, and again when a run starts, against the hive’s current agents. Diagnostics have the same shape as a lifecycle model’s compiler diagnostics. Errors block enabling and starting.

CodeSeverityCause
task-invaliderrorWrong apiVersion or kind, no steps, or a step with no prompt
task-bad-nameerrorA workflow name, step id or pool name that breaks the naming rule, or a reserved workflow name
task-duplicate-steperrorTwo steps share an id
task-unknown-deperrordepends_on names no step
task-cycleerrorA step depends on itself, or the graph has a cycle; the message names one, for example a -> b -> a
task-no-agenterrorA step sets neither agent nor pool, or both
task-unknown-agenterrorA step’s agent, or a pool member, is not a configured agent on this hive
task-unknown-poolerrorpool names no entry in spec.pools
task-empty-poolerrorA pool has no members
task-duplicate-pool-membererrorAn agent is listed twice in one pool
task-duplicate-paramerrorA param is declared twice
task-bad-templateerrorA prompt references an undeclared param, a step that is not an ancestor, or an unknown name
task-missing-paramerrorThe schedule does not set a required param that has no default
task-bad-scheduleerrorThe cron expression or tz is missing or does not parse, or the schedule sets an undeclared param
task-bad-durationerrorA timeout or backoff that is not a valid duration
task-bad-notifyerrorThe notify URL is not an absolute http(s) URL, carries credentials or is refused, or an event is not run or step
task-bad-fielderrorA bad param name, on_failure or approval value, or a dependency listed twice
task-limiterrorA limit below is exceeded
task-agent-has-cadencewarningAn agent also has an active governor cadence, which can compete with workflow steps
task-sandbox-agentwarningAn agent runs sandboxed kicks and reports through the sandbox request spool

Limits:

LimitValue
Steps per workflow50
Params per workflow32
depends_on per step50
Prompt template8,000 characters
retry.max_attempts10
retry.backoff, retry.max_backoffat most 24h
retry.factor1 to 10
Step timeout1m to 24h
Run timeoutat most 7 days
spec.concurrency1 to 50
Pool members16
Description1,000 characters
Result kept per step16 KiB (longer results are truncated and marked)

How a run executes

A run is a copy of the workflow as it was saved when the run started: editing the workflow never changes a run in flight, and Re-run starts a new run of the current spec with the same params. The runner is one loop in the hive process that ticks every 2 seconds and is the only writer of run state, which is saved after every change and reloaded on restart.

Ready steps

On each tick, for each active run, the runner:

  1. ends the run’s unfinished steps if the run’s spec.timeout has passed;
  2. fails attempts that timed out, or whose agent’s turn ended without a report;
  3. moves steps whose retry wait has elapsed back to the queue;
  4. marks a step ready once every step in its depends_on has succeeded, and skips it once any of them failed, was skipped or was cancelled. A ready step with approval: required waits in awaiting-approval; any other ready step is queued;
  5. kicks queued steps, oldest ready first (ties in declaration order), on free agents, under the concurrency caps;
  6. ends the run once every step has finished.

hive-step-done reports are applied as they arrive, just before each tick.

The agent chosen for each step

A step with agent runs only on that agent. A pool step may run on any member that is free:

  • known to the runtime, running and not paused, with no kick delivery in flight;
  • not holding another task workflow attempt, from any run (an agent takes one attempt at a time);
  • not cooling down after a failed delivery (30 seconds);
  • not over the governor’s budget.

Among free members, the runner prefers one whose last turn is known to have ended, then one other than the agent that ran the step’s previous attempt, then the order of the pool’s list. A pool of N agents can run N steps at once; a step that names one agent serialises with every other step that names it. A step is kicked through the same runtime call as the dashboard’s kick button, so the agent’s mode, permissions, credentials and egress rules apply unchanged, and each kick counts against the governor’s spend.

Concurrency

Two caps apply together: spec.concurrency limits the steps running at once in one run (default 4), and workflow.tasks.max_concurrent_steps limits them across the hive (default 4). A queued step that is under both caps but has no free agent waits. Separately, a workflow never has two active runs, and workflow.tasks.max_active_runs (default 8) caps active runs across the hive.

Run and step states

Run statusMeaning
runningStarted; steps are being scheduled
pausedAt least one queued step has only over-budget agents to run on. Steps with an agent under budget still start, running attempts continue, and the run returns to running once no queued step is blocked by budget
succeededEvery step succeeded
failedEvery step has finished and at least one did not succeed, including a run timeout
cancelledCancelled by a merger or owner
Step statusMeaning
pendingWaiting for its dependencies
awaiting-approvalReady, held by approval: required until an owner approves it
queuedReady, waiting for a free agent or a concurrency slot
runningAn attempt has been sent to an agent
retry-waitAn attempt failed; waiting out the backoff before the next attempt
succeededAn attempt reported succeeded; its result is available to dependants
failedThe last allowed attempt failed; or the step could not be rendered (render-failed, prompt-too-long); or it was waiting for a retry when a stop policy ended the run; or its attempt was running when the run timed out
skippedCan no longer run: a dependency did not succeed, the run is stopping, or the run timed out before it finished
cancelledThe run was cancelled before the step finished

Each attempt records its agent, when it was delivered, when the agent’s turn ended, its status (dispatching, running, succeeded, failed, cancelled), result and failure reason.

Reporting completion

The framed prompt tells the agent to finish with exactly one of:

hive-step-done --run <run-id> --step <step-id> --attempt <n> --status succeeded --result "<short result>"
hive-step-done --run <run-id> --step <step-id> --attempt <n> --status failed --result "<why>"

--result-file <path> can replace --result for a longer result. A report is accepted only when the run is active, the step’s current attempt is still active (being delivered or running) with that attempt number, and the reporting agent, identified by the UID that owns the request file and never by a name in it, is the agent the attempt was sent to. The first report wins. A request file whose owner UID does not identify exactly one agent, or names another agent, is denied at the relay and logged; a late, duplicate or mismatched report from an identified agent is refused and audited as task_workflow_step_report_refused. Reports reach hive through the in-pod drop box, so steps should run on agents in the hive pod.

Failure, retries and timeouts

An attempt fails, with the reason recorded on it, when:

ReasonCause
reported-failedThe agent reported --status failed
timeoutThe step’s timeout passed, measured from delivery of the kick
no-reportThe agent’s turn ended and workflow.tasks.report_grace (default 30s) passed with no report
preemptedThe agent was kicked by something else before it reported
agent-unavailableThe agent stopped or was paused, or the runtime refused the kick
delivery-failedThe step’s kick could not be delivered for the fifth time (a busy pane, a stuck delivery); before that, a failed delivery re-queues the step without using an attempt
run-timeoutThe run’s spec.timeout passed while the attempt was running

Two reasons fail the step at once, with no retry, because a retry would fail the same way: render-failed (a template reference with no value) and prompt-too-long.

When an attempt fails and the step has attempts left, the step waits out its backoff in retry-wait, then queues again; a pool step’s retry prefers a different member. Hive does not interrupt an agent whose attempt timed out; it stops waiting for it, and a late report from that attempt is refused.

When a step has used all its attempts, on_failure decides what happens to the rest of the run:

  • stop (default): no new step starts in this run. Attempts already running finish and their outcomes are recorded, steps waiting for a retry fail, and every step that never started is skipped. The run ends failed.
  • continue: the step’s dependants, direct and transitive, are skipped, and every branch that does not depend on it keeps going. The run still ends failed, because a step failed, but everything that could run did.

on_failure: continue does not make a failure count as success: a fan-in step that depends on a failed step is always skipped.

When spec.timeout passes, running attempts fail with run-timeout, every other unfinished step is skipped, and the run ends failed. The run timeout is wall-clock time and keeps counting while the run is paused for budget.

Cancel (merger or owner) marks every unfinished step and running attempt cancelled and ends the run cancelled. An agent already working is not interrupted; its late report is refused.

Starting runs

Every trigger starts the same thing: a run of a saved, enabled workflow with a params map, checked against spec.params. A start while the workflow already has an active run is refused with 409, and past workflow.tasks.max_active_runs with 429.

  • Dashboard and API. Run now on the workflow’s page, or POST /api/task-workflows/{name}/runs with {"params": {...}}, which answers 202 with the run id. Only an owner may pass params; a merger may start a run on the defaults. See Start, watch and cancel runs.
  • Schedule. spec.schedule takes a five-field cron expression, a required tz and the params to start with. A fire while a run is still active, or while the active-run cap is reached, is skipped and audited as task_workflow_schedule_skipped; fires missed while hive was down or while workflow.tasks.schedules_enabled was off are not replayed. See Schedule runs.
  • External triggers. An owner creates a run-trigger token scoped to one workflow; an external scheduler or CI system presents it on POST /api/task-workflows/hooks/{name}/runs to start a run and on GET /api/task-workflows/hooks/{name}/runs/{run} to poll its status, and can do nothing else. See Trigger runs from an external scheduler.
  • Notifications. With spec.notify, the hive switch workflow.tasks.notify.enabled and a signing secret, hive emits a step event when each step reaches a terminal state, including cancellation, skipping, timeouts and failures before a kick, and a run event when the run finishes. Delivery is best effort, with bounded retries. See Notify another system and Task workflow notifications.

What is and is not executed

Done by
Ordering steps, retries, backoff, timeouts, concurrency caps, approval holdsHive’s runner
The work of each stepThe step’s agent, in its own session, with its own permissions and credentials
Deciding successThe agent’s hive-step-done report; a turn that ends without one fails the attempt
Container steps, shell commands, CI jobsNot run by hive; a step is always an agent prompt

A DAG workflow adds no permission. What an agent may do on GitHub or anywhere else is decided by its mode, ACMM level, credential helper and the egress proxy, exactly as for a kick from the dashboard. Where a step’s agent opens a pull request, the repository’s review and merge gates still apply.

How it shows in the dashboard

  • Task workflows (Settings → Workflows): every workflow with its enabled state, the YAML editor with Validate and its diagnostics, Run now with the param form (owners), and run-trigger tokens. The notification signing secret is managed through the API (POST and DELETE /api/task-workflows/{name}/notify/secret).
  • Run page: the steps laid out by stage (stage 1 has the steps with no dependencies, each later stage the steps whose dependencies are all in earlier ones), each coloured by state; every attempt with its agent (linked to that agent’s kicks), status, duration, failure reason and result, and Kick log for the redacted record of that kick. Cancel run, Re-run and Approve on held steps. An active run refreshes itself every few seconds; secret-shaped text in results and reasons is masked.
  • Settings: every workflow.tasks knob, listed in the user guide.

Worked example

A release-readiness check before cutting a release. One step gathers what changed; three steps then work on it in parallel; a final step assembles the release notes and upgrade guide, after an owner has looked at the drafts. The agents are release-lead, a pool of two documentation agents docs-1 and docs-2, and a scanning agent scanner-1, all configured on the hive with their cadences paused.

The same graph as text:

              ┌──▶ notes ─────────┐
collect ──────┼──▶ upgrade-guide ─┴──▶ assemble (approval: required)
              └──▶ security-scan

release-readiness.yaml:

apiVersion: workflow.hivecommons.dev/v1alpha1
kind: TaskWorkflow
metadata:
  name: release-readiness
  description: Draft release notes and an upgrade guide, and scan the changes, before a release
spec:
  params:
    - { name: version, required: true, description: The version about to be released }
    - { name: repo, default: example-org/example-app }
  pools:
    docs: [docs-1, docs-2]
  concurrency: 3
  timeout: 4h
  steps:
    - id: collect
      agent: release-lead
      prompt: |
        List the pull requests merged into {{params.repo}} since the previous release,
        for version {{params.version}}. Store the list in the shared release folder and
        report its URL as the result.
      retry: { max_attempts: 2, backoff: 1m }
      timeout: 30m
    - id: notes
      pool: docs
      depends_on: [collect]
      prompt: |
        Draft release notes for {{params.version}} from the list at {{steps.collect.result}}.
        Report the draft's URL as the result.
      retry: { max_attempts: 3, backoff: 2m }
    - id: upgrade-guide
      pool: docs
      depends_on: [collect]
      prompt: |
        From the list at {{steps.collect.result}}, find changes that need action from users
        upgrading to {{params.version}} and draft an upgrade guide. Report its URL.
    - id: security-scan
      agent: scanner-1
      depends_on: [collect]
      prompt: |
        Review the changes listed at {{steps.collect.result}} for security issues.
        Report a one-line summary and the URL of your findings.
      on_failure: continue
    - id: assemble
      agent: release-lead
      depends_on: [notes, upgrade-guide]
      approval: required
      prompt: |
        Combine the release notes at {{steps.notes.result}} and the upgrade guide at
        {{steps.upgrade-guide.result}} into the release description for {{params.version}}
        (changes from {{steps.collect.result}}). Report its URL.

Starting it:

curl --fail-with-body -X POST https://hive.example/api/task-workflows/release-readiness/runs \
  -H "Authorization: Bearer $HIVE_TOKEN" -H 'Content-Type: application/json' \
  -d '{"params":{"version":"2.4.0"}}'
# => 202 {"ok":true,"run_id":"r-...","status":"running"}

What happens:

  1. Stage 1. collect is the only step with no dependencies, so it is queued and sent to release-lead with repo filled from its default. If it reports failed, or its turn ends without a report, it waits one minute and tries once more. If that fails too, collect has on_failure: stop (the default): nothing else starts, the other four steps are skipped and the run ends failed.
  2. Fan-out. Once collect reports succeeded with the list’s URL, notes, upgrade-guide and security-scan are all ready on the same tick. notes goes to docs-1 and upgrade-guide to docs-2 (the pool’s two free members), and security-scan to scanner-1: three steps at once, within concurrency: 3 and the hive-wide default cap of 4. Each prompt receives {{steps.collect.result}}.
  3. An independent branch fails. Suppose security-scan reports failed. It has one attempt and on_failure: continue, so it is failed and only its dependants would be skipped; it has none, so notes and upgrade-guide carry on. The run will end failed whatever else happens, and the scan’s failure reason is on the run page.
  4. A retry on another member. Suppose notes fails on docs-1. It waits two minutes in retry-wait and is queued again. Among free members the runner prefers one whose last turn has fully ended, then one other than docs-1, so if docs-2 has finished upgrade-guide by then, attempt 2 usually goes to docs-2; if only docs-1 is free, it goes back to docs-1.
  5. Fan-in and approval. When both notes and upgrade-guide have succeeded, assemble is ready, and because of approval: required it waits in awaiting-approval. An owner reads the two drafts and chooses Approve (or POST /api/task-workflows/release-readiness/runs/<run-id>/steps/assemble/approve); the step is then queued and sent to release-lead. Had notes used all three attempts and failed, its default stop policy would have ended the run instead, and assemble would be skipped.
  6. The end. When every step has finished, the run ends: succeeded only if all five steps succeeded. The whole run is bounded by timeout: 4h, including the time assemble waits for approval.

Two variations validation would refuse: assemble using {{steps.security-scan.result}} (task-bad-template: the scan is not an ancestor of assemble, so its result might not exist), and collect depending on assemble (task-cycle, reported as collect -> assemble -> notes -> collect).

Next steps

  • Follow the task workflows guide for a complete regression pipeline, run-trigger tokens and every workflow.tasks setting.
  • Have an existing pipeline? Import it from GitHub Actions or Tekton as a disabled draft, then write a prompt and choose an agent for each step.
  • Send run and step results to another system with task workflow notifications.
  • Read the design for the reasoning behind the runner, reporting and safety model.