Appearance
Workflows
An agent left to choose its own process can skip a validator or loop all night. A workflow is a file of fixed steps that the agent must follow and cannot change. Read this page if you write or review workflows and want to know every path a run can take.
The example on this page is illustrative.
Five words to read any workflow
You need five words to read any workflow. This file plans the work, waits for you, works through the plan and delivers the result.
yaml
format: daggry/workflow@1
steps:
- id: plan
kind: agent
engine: <engine>
prompt: Write the plan.
outputs: [plan]
scope: nothing
- id: approve-plan
kind: human
waiting_for: approval
- id: work-through-plan
loop:
over: plan
as: criterion
until: verdict.all_covered
max: 5
on_exhausted: fail
steps:
- id: work
kind: agent
engine: <engine>
prompt: Do the work for this plan item.
outputs: [change]
scope: ["docs/**"]
- id: validate
kind: verify
validators: [project, daggry/criterion-coverage]
- id: deliver
kind: effect
do: publish<engine> stands for the engine the step uses. The list defines the five words.
- A step is one unit of work. It has a kind:
agent,command,verify,humanoreffect. - An output is what a step hands to the next step, such as
plan. Daggry seals it, so a later step cannot rewrite it. - A loop repeats steps once for each plan item, up to a loop limit. The file calls a plan item a criterion.
- A gate is the rule that decides whether a loop can stop. Here it is
until: verdict.all_covered. - An approval is a point where the run stops until you approve. Here it is the
humanstep.
The last step is an effect: the step that delivers the result, for example by opening a pull request. To write a file like this one, follow Write a workflow.
Loops always end
A loop is where an agent can run all night, so every loop has a limit. After each iteration, Daggry reads the gate. If the validators passed, the loop moves to the next plan item. If they failed, the same plan item repeats. When the loop reaches its limit, the run fails or waits for you, whichever the file says.
One iteration for each plan item, up to the loop limit
- agentWrite the proofa test for the next plan item
- codeShown to failbefore the work
- agentDo the workchange the paths in scope
- codeRun again on a clean copyevery validator
Plan items left, or this one failed: another iteration
Gatethe rule that lets the loop stop
- every plan item coveredNext step
- loop limit reachedFails, or a person decides
human step the workflow names. In software, the proof is a test. The diagram shows one iteration of a loop, the gate after it and the exit when the loop limit is reached. In the iteration, an agent writes a proof for the next plan item, and code shows that the proof fails before the work. The agent then does the work, and code runs every validator.
A proof is a test the run writes that fails first, then passes. A test that already passes says nothing about the work. Once Daggry seals the proof, the agent cannot edit it. See Add a loop.
You decide where a person is needed
Some decisions are yours, and an agent that guesses them can build the wrong plan to the end. An approval stops the run where you chose and shows why. Most workflows have two: approve the plan before work starts, and review the result before it is delivered.
Waiting for you
Approve this plan
Why it stopped: this workflow asks a person to approve every plan before any work starts.
Revise the travel expenses policy
- State the daily limit for meals
- Name who approves an exception
- Link every rule to its source
- Define each term once
- Give the date the policy takes effect
To approve, run: daggry approve <run-id>
Approved
Approved by you at 22:04
Recorded against the plan you saw, not only the plan's name.
recorded by codeapproves plan 9c1e
If anyone changes the plan afterwards, its fingerprint changes and your approval no longer matches it. The run goes on overnight.
The diagram shows an approval card moving from Waiting to Approved, with the reason shown while it waits. Daggry records your approval against the exact plan or change you saw, so a later edit cannot use it.
The file fixes, the run decides
Read this table to know what a run can and cannot vary. The file fixes everything that makes a run predictable before the run starts.
| The file fixes | The run decides |
|---|---|
| The order of steps and loops | How many iterations a loop needs, one for each plan item |
| The limit on every loop, and whether the run fails or waits for you at the limit | Whether a loop stops early because its gate already holds |
| Where the run stops for an approval | Which paths each step changed |
| The paths each step can write | Whether those paths stayed in scope |
A gate reads only what code computed from sealed records, never what an agent said. For the syntax, see Gate expressions.
What can a workflow not do?
An agent never adds, removes or reorders steps. Daggry keeps the file outside every workspace.
A workflow has no if. A run branches only at a gate, a loop or an approval. Steps run in order, and a loop cannot hold another loop. For every key and every file Daggry refuses, see the Workflow file reference.
Related: