Browse documentation
Tutorials
View Markdown
On this page

Tutorials

The tutorials are a path through the big picture of the quickstart, one box at a time. Each one introduces one main idea and says what it added. They follow one running example: the help desk of a small online shop, from the life of a support ticket to an agent that refunds damaged orders with a person's approval, survives a crash, and talks with the customer.

You need gvn installed. The quickstart is a ten-minute taste before you start, and it draws the picture this page refers to.

The route through the big picture

Here is the quickstart's picture again, with the tutorial that opens each box. The one box the quickstart left out is the output, where the Governor reports what a run is doing while it happens; tutorial 7 adds it.

flowchart LR
    you(["You, or your application"])
    person(["A person who approves<br/><i>5, 10</i>"])
    subgraph run ["One run"]
        direction TB
        governor["<b>Governor</b><br/><i>3, 9</i>"]
        actor["<b>Actor</b><br/>a verified state machine<br/><i>1, 2, 3, 8, 10</i>"]
        governor -- "event" --> actor
        actor -- "request" --> governor
    end
    fulfillers["<b>Fulfillers</b><br/>model <i>3, 12</i> · tools <i>4, 12</i> · policy <i>5</i>"]
    journal[("<b>Journal</b><br/><i>6</i>")]
    output["<b>Output</b><br/><i>7</i>"]
    you -- "event: started" --> governor
    governor -- "request" --> fulfillers
    fulfillers -- "event" --> governor
    governor -- "records" --> journal
    governor -- "reports" --> output
    governor -- "asks" --> person
    person -- "answer" --> governor

In words, the path goes from the inside out:

  • Tutorials 1 and 2: the state machine at the centre. You build one with gvn's kernel alone, see what the verifier checks, and branch on data. No model, no runtime.
  • Tutorials 3 to 7: one agent, and the runtime around it. The ready-made agent is an actor; the Governor and its fulfillers do the work it asks for (3), including your tools (4) and your policy, with a person approving (5). Then the journal lets a run outlive its process (6), and the output shows a run while it happens (7).
  • Tutorials 8 to 10: actors made of actors. A workflow runs agents as its steps (8), gives a step a deadline (9), and a conversation talks with a person over many turns (10).
  • Tutorials 11 and 12: from fakes to the real thing. Tests that replace every outside piece with a fake (11), then a real model, a real journal, a real clock and ready-made tools in place of the fakes (12).
  • Tutorial 13: your own job. The whole picture once more, this time as a checklist of questions about your harness, with a worked example that is not the help desk and a file to start from.

The tutorials

# Tutorial The one new idea Box Time
1 A first machine a state machine, and what the verifier checks Actor 10 min
2 Decisions and branching branching on data through a Decision Actor 15 min
3 An agent with a scripted model actors ask; the Governor does the work Actor, Governor, model 10 min
4 Adding a tool tools, and what the agent does with them tools 15 min
5 A policy, and approval by a person waiting for a person is a state policy, person 20 min
6 The journal: crash and resume a run outlives its process Journal 15 min
7 Streaming, and seeing what happened watching a run while it happens, through its output Output 10 min
8 A workflow of two actors a machine whose steps (stages) run other actors Actor 15 min
9 A deadline time as journaled events Governor 15 min
10 A conversation many turns with a person Actor, person 10 min
11 Testing your harness fast offline tests, including a crash at every journal write every box 15 min
12 A real model and ready-made tools swapping the edges, not the harness model, tools 15 min
13 Your own harness the same picture, asked about your job every box 15 min

How each page works

Each page starts by saying what you can do at the end, where its subject sits in the picture and what the previous one left you with.

Start a new file for each page, and begin it with the collapsed block near the top of the page. That block holds everything the page uses from earlier pages, imports included. Then add each block of the page below it, in order, and run the file as you go. The first step is the same whether you have just finished the page before or open this one on its own.

Each page ends with a Change it and run again check, a recap and a link to the next page. The check asks you to make one or two small edits and predict what happens; the real result is in a collapsed block, so you can decide first and look after. The documentation tests execute the offline walkthroughs in page order. Tutorial 12 also includes provider examples that require a credential and network access. When a page uses a word from an earlier page, it links to it. The glossary has every term in one place.

The first two tutorials teach the control-flow vocabulary; tutorial 3 then starts the help-desk agent using those ideas. You do not need to carry the ticket-machine code into the agent. From tutorial 4 onward the examples extend that help desk.

If you came from the quickstart: run_agent hid a few pieces so you could see an agent work in one call: the state machine that is the agent, the runtime that does the work it asks for (the Governor), the journal that records every event, the policy that decides which tool calls run, and the person who approves the rest. The tutorials take those pieces out one at a time, so you can choose each one yourself. Nothing you learn here replaces what you ran: it is what run_agent builds, and the short path shows the two side by side.

After the tutorials

If you came to build a harness of your own, finish with 13. Your own harness: it turns the tutorials into a design checklist for your job and gives you a file to start from.

The Concepts explain each idea in depth, and the Guides are recipes for specific tasks. When you begin packaging larger subsystems, use Designing a large harness; the interface contract map helps you look up extension obligations without repeating the full tutorial.