# Reading a harness drawing

**Who this page is for:** anyone reading a harness in the Workbench: what each mark on a
drawing means, and how to go from a workflow to the actors it runs.

A **drawing** is one actor's state machine as gvn verified it: its states, the transitions
between them, and the work it asks for. For a workflow, the drawing also shows each stage:
which actors it runs, how, and where each way of ending leads. A harness opens on the drawing
of its entry actor; every child actor opens on a drawing of its own.

- **You will be able to:** read states, transitions and outputs on a Moore and on a Mealy
  machine, read a stage's recipe, join and endings, and move between the drawings of one
  harness.
- **Read first:** [Your first session](first-session.md). [Machines](../concepts/machines.md)
  and [Workflows](../concepts/workflows.md) teach the ideas behind the marks.
- **Time:** about 15 minutes.

## Where a drawing comes from

```mermaid
flowchart LR
    harness["Harness<br/>actor_class()"]
    entry["Entry actor<br/>its Definition"]
    plan["Its Plan<br/>(a workflow)"]
    stage["A stage<br/>Host · ForEach · FanOut · Parallel"]
    child["A child actor class<br/>its Definition"]
    drawing["Drawings<br/>one per actor"]
    harness --> entry
    entry -- "a workflow has" --> plan
    plan --> stage
    stage -- "runs" --> child
    child -- "a workflow has" --> plan
    entry --> drawing
    child --> drawing
```

The Workbench starts from the harness's entry actor class (`Harness.actor_class()`; see
[Harnesses](../concepts/harnesses.md)), reads its verified
[definition](../reference/glossary.md#definition), and, for a workflow, its
[plan](../reference/glossary.md#plan): the stage behind each state and the actor class each
stage runs. It goes down the same way for every child that is itself a workflow. It reads only
what those objects answer: it never runs a harness and never calls the functions that build a
child (`make`, `start`). A setting the stage computes only by running the project's code, such
as how many copies a `FanOut` makes, is not shown.

So the drawing is the machine that runs, not a picture someone keeps up to date. Change the
Python, and the next drawing changes with it.

## The parts of a drawing

| Mark | What it means |
|---|---|
| A box | A [state](../reference/glossary.md#state). The actor is in exactly one state at a time. |
| A box tagged **Start** | The initial state: where the actor is before anything has happened to it. |
| A box tagged **End** | A [final state](../reference/glossary.md#final-state). Once there, the actor has finished and its outcome is fixed. |
| An arrow | One or more declared [transitions](../reference/glossary.md#transition) between two states, one line per transition, each naming its input. |
| A name on a state (Moore) | What the state emits on entering it. |
| `input / output` on an arrow (Mealy) | The input, and what taking the transition emits. |
| The line above the drawing | The otherwise rule: what every other input does. |

The details panel beside the drawing describes the selection. With nothing selected, it
describes the whole machine: where it starts, what any other input does, where its class is
defined (file and line in the project, or the gvn module for gvn's own actors) and its
[fingerprint](../reference/glossary.md#fingerprint). Selecting a state shows the inputs it
leaves on and the states it is entered from; selecting an arrow shows each transition on it:
source, input, destination and, on a Mealy machine, output.

The **Drawing / List** switch shows the same machine as two tables, states and transitions,
in the definition's own order. The list is the way to read a machine with a keyboard or a
screen reader, and it holds exactly what the drawing holds.

## Moore and Mealy

gvn has two styles of machine, and a drawing puts the output where its style puts it.

- A **Moore machine** names its output per state: being in `collecting_evidence` asks for
  `collect_evidence`. Workflows and gvn's reference agent are Moore machines. The release
  review's `ReleaseReview` is one.
- A **Mealy machine** names its output per transition: taking `checking` → `ready` on
  `all_present` emits `mark_ready`. The release review's `ChecklistGate` is one: what it
  emits depends on the input as well as the state.

The line above the drawing says which: "A Moore machine: what it emits is written on each
state", or "A Mealy machine: what it emits is written on each arrow, after the input".
[Machines](../concepts/machines.md#two-styles-moore-and-mealy) has the full story.

## The otherwise rule

Every gvn machine is complete: for every state that is not final and every input, it says
where the machine goes. Most of those pairs mean "this does not apply here", so a machine
declares them once, as its **otherwise** rule, instead of one arrow each. A drawing shows only
declared transitions as arrows and states the rule once, in words:

- a Moore machine: any other input, it stays where it is and emits nothing new;
- a Mealy machine: any other input, it stays where it is and emits the rule's output
  (`ignore`, for `ChecklistGate`).

In a recorded run, a step taken by the otherwise rule is marked as such: the actor stayed,
and the step was not declared. [Machines](../concepts/machines.md#step-2-say-what-happens-otherwise)
explains why gvn keeps the two apart.

## Stages and recipes

In a workflow's drawing, a state that runs other actors is a **stage**. Selecting it shows
how it runs its children, in plain words with the gvn name beside them:

| In plain words | gvn recipe | What it runs | In the release review |
|---|---|---|---|
| Runs one | `Host` | one child actor | `validating` (the checklist gate), `awaiting_approval` (the release manager's question) |
| Runs one per item | `ForEach` | one child per item of a list from the workflow's own data, a few at a time (`window`), with retries (`retry`, `attempts`) | `reviewing_components`, one reviewer per component |
| Runs several copies | `FanOut` | several children of one actor class | `cross_checking`, the same checker twice |
| Runs these side by side | `Parallel` | one child per branch, each of its own class | `collecting_evidence`, an Agent and an Errand |

The panel lists the stage's children, each with a button that opens its machine, and the
stage's **settings** as the stage object answers them: `routes` or `judge` for a `Host`,
`window`, `limit`, `attempts` and `retry` for a `ForEach`, `empty` for a stage that may have no
children, `deadline` and `expired` for a stage with a time limit, and `retain`. A setting the
recipe does not have is not listed.

A recorded run's children are **instances** of these. The drawing of a harness shows each
child once, as a template; a run page shows how many instances of it the run made (see
[Reading a run](runs.md#instances-of-a-template)).

### How a child's ending becomes an input

When a stage's children end, the stage gives the workflow one input. The panel says which of
three ways it does that:

- **Routed** (`Host` with `routes`): the state the child ends in picks the input. For
  `validating`, `ready` gives `checklist_complete` and `incomplete` gives
  `checklist_incomplete`.
- **Judged** (`Host` with a `judge`): a [Decision](../concepts/decisions.md) reads how the
  child ended, more than its final state, and picks the input. For `awaiting_approval`,
  `ReleaseDecision` reads the release manager's choice.
- **Joined** (`ForEach`, `FanOut`, `Parallel`): a join reads the group of children; see below.

### Joins

A **join** decides when a stage with several children is over and which input that gives. The
panel names its class and settings:

| Join | Settings shown | When it ends the stage |
|---|---|---|
| `AllOf` | `success`, `reached`, `missed` | `reached` when every child succeeded; `missed` once one did not |
| `AnyOf` | `success`, `reached`, `missed` | `reached` as soon as one succeeded; `missed` when none did |
| `Quorum` | `count`, `success`, `reached`, `missed`, `wait` | `reached` once `count` children succeeded; `missed` once that can no longer happen |
| `Worst` | `order`, `early` | the worst verdict present, worst first in `order`; a verdict in `early` ends the stage at once |

In the release review, `collecting_evidence` uses `AllOf` with success `ready`: the stage gives
`evidence_ready` only when both branches' verdicts are `ready`. `reviewing_components` uses
`Worst` with `early = ["blocked"]`: one blocked component ends the stage at once with
`component_blocked`, and the components not yet reviewed are never started.
[Workflows in depth](../concepts/workflows-in-depth.md#joins-when-is-a-fan-out-over) has the
rules in full.

### Where each ending leads

Under the heading **Where each ending leads**, the panel lists every input the stage can end
with and the state the workflow then moves to. It is the stage's half of the workflow's
transitions, and it includes inputs the stage gives on its own: the `expired` input of a stage
with a deadline, and the `empty` input of a stage that has no children to run. For
`awaiting_approval`:

| Ending | Leads to |
|---|---|
| `release_approved` | `approved` |
| `changes_requested` | `needs_changes` |
| `approval_withdrawn` | `needs_attention` |
| `approval_timed_out` (the deadline passed) | `needs_attention` |

## Moving between drawings

A harness opens on its entry actor. From a stage, a child's button opens that child's
drawing; a child that is itself a workflow opens on its own stages, and so on down.

- The **breadcrumb** at the top names every drawing from the harness down to this one; each
  name is a link back.
- The **back** button returns to the drawing one level up.
- The address in the browser names the harness and the child's **template path**, so a link
  to a drawing can be shared.

A **template path** says where an actor sits in the harness as written: the stage names from
the entry actor down, joined by `/`. Inside a `Parallel` stage, the branch's index follows the
stage's name. In the release review:

| Template path | Actor |
|---|---|
| (empty) | `ReleaseReview`, the entry actor |
| `validating` | `ChecklistGate` |
| `collecting_evidence/0` | the summarising `Agent` (branch 0) |
| `collecting_evidence/1` | the CI `Errand` (branch 1) |
| `reviewing_components` | the reviewing `Agent`, one template for every component |
| `cross_checking` | the checking `Agent`, one template for both copies |
| `awaiting_approval` | the `Inquiry` to the release manager |

Every instance a run makes of one template (every item, every copy, every visit, every attempt)
has that same template path. See [template](../reference/glossary.md#template).

## Words on the page

Each drawing ends with the words it uses, each in one sentence, with a link to the page that
explains it. The guide answers "what is this?" for any of them; see
[The guide and coding agents](guide-and-agents.md).

## Recap

- A drawing is an actor's verified definition: states, declared transitions, outputs on states
  (Moore) or on arrows (Mealy), and the otherwise rule stated once.
- A workflow's stage shows its recipe, its children, its settings, how a child's ending becomes
  an input (routed, judged or joined) and where each ending leads.
- A child opens on its own drawing; the breadcrumb and the back button go up again; the address
  names the template path.

**Next:** [Reading a run](runs.md).
