Private preview. Daggry is not publicly released.Roadmap
Skip to content

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, human or effect.
  • 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 human step.

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

  1. agentWrite the proofa test for the next plan item
  2. codeShown to failbefore the work
  3. agentDo the workchange the paths in scope
  4. 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
Each iteration takes one plan item through four steps, two by the agent and two by code: the agent writes a proof, code shows that the proof fails before the work, the agent does the work, and code runs every validator on a clean copy. The gate lets the run go on only when every plan item is covered. At the loop limit, the run fails, or it waits for you at the 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

  1. State the daily limit for meals
  2. Name who approves an exception
  3. Link every rule to its source
  4. Define each term once
  5. Give the date the policy takes effect
plan fingerprint 9c1e

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.

An approval. The run stops where the workflow asks for your approval, and says why. Your approval is recorded against the fingerprint of the exact plan you read, so it cannot be moved to a different plan.

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 fixesThe run decides
The order of steps and loopsHow 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 limitWhether a loop stops early because its gate already holds
Where the run stops for an approvalWhich paths each step changed
The paths each step can writeWhether 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:

Sponsored by