The model behind gvn¶
What you will learn: how the whole of gvn fits together, first as a running loop and then as layers of code, and which page in this section explains each part. Every later concepts page starts by pointing back to one box of the pictures on this page.
Read first: the quickstart, which introduces the loop below with a runnable example. The tutorials are the hands-on path; this section explains why the pieces exist and how they fit. Time: about 10 minutes.
The one idea¶
gvn separates deciding what happens next from doing the work. The deciding is done by a state machine: a fixed list of states, a fixed list of inputs, and for every pair a declared answer, "in this state, when this input arrives, go to that state". gvn's verifier checks that every pair has an answer before the machine may run. The doing (calling a model, running a tool, saving a record) happens elsewhere, in code the machine never touches.
Everything in gvn is arranged around that split. You can look at it two ways: as a loop that runs (what happens during one run), and as layers of code (what imports what). This page shows both, then maps each part to the page that explains it.
Picture 1: the loop that runs¶
flowchart LR
you(["You, or your application"])
person(["A person"])
subgraph run ["One run"]
direction TB
governor["<b>Governor</b><br/>drives the run"]
actor["<b>Actor</b><br/>a verified machine + its data"]
governor -- "event" --> actor
actor -- "requests" --> governor
end
fulfillers["<b>Fulfillers</b><br/>model · tools · policy · clock"]
journal[("<b>Journal</b><br/>every event, in order")]
you -- "event: started" --> governor
governor -- "request" --> fulfillers
fulfillers -- "event" --> governor
governor -- "records" --> journal
governor -.->|"waits for"| person
person -- "event: an answer" --> governor
One turn of the loop, part by part:
- Event. Something that happened, with its data: a run was started, the model replied, a tool returned, a person approved. An event is the machine's input name plus a payload, the data that came with it. Actors and events explains events.
- Governor. The object that drives a run. It hands the event to the actor, then records it before starting the work the actor requests. The Governor explains it.
- Actor. A state machine with a job and the data that job needs: an agent, a workflow, a conversation. Given an event, it moves to its next state and says what work it wants. It never does that work itself. Its machine is explained in Machines, how it branches on data in Decisions, how it is saved in Durable objects, and how it takes events in Actors and events.
- Request. Work the actor wants done, with its data: "call the model with this transcript", "run these tool calls", "ask the policy about them". A request is the machine's output name plus a payload. Also in Actors and events.
- Fulfiller. The object that does one kind of request: one calls the model, one runs
tools, one asks your tool policy (your rule for whether a tool call may run, needs a
person's approval, or is refused), one waits for a time. What it finds out comes back as the
next event. Fulfillers reach the outside world only through ports: abstract classes
such as
Model,JournalandClockthat say what an outside service must offer, so that any implementation of one can be plugged in. Explained in The Governor. - Journal. The ordered record of the events delivered to the actor by the runtime. With a durable journal, gvn rebuilds the actor after a crash by restoring a snapshot and applying later events. Also in The Governor.
- A person. Some requests are answered by nobody inside the process: "approve this tool call", "answer this question". The Governor records that the run is waiting and returns; nothing blocks. Days later, the person's answer arrives as an ordinary event and the loop continues. Humans and interruption and Asking a person explain this.
The loop repeats until the actor's machine reaches a final state, one that ends the run.
Picture 2: the layers of code¶
The same parts, arranged as the code is. Each ring may import only the rings inside it, so the inner rings never know the outer ones exist:
flowchart TB
shortcuts["<b>shortcuts</b><br/>run_agent: the pieces below wired in one call"]
adapters["<b>adapters</b><br/>one module per real system: Anthropic, OpenAI, SQLite, Postgres, OpenTelemetry"]
runtime["<b>runtime</b><br/>the Governor, the fulfillers, recovery, replay"]
harness["<b>harness</b><br/>actors (agent, workflow, conversation…), tools, messages, events, ports"]
kernel["<b>kernel</b><br/>machines, the verifier, decisions, durable objects, schemas"]
shortcuts --> adapters --> runtime --> harness --> kernel
tools["<b>gvn-tools</b><br/>ready-made tools"] --> harness
domains["<b>gvn-domains</b><br/>complete harnesses by field"] --> shortcuts
testing["<b>test kit</b><br/>fakes for every port, beside the adapters"]
An arrow means "may import"; code may also import any ring deeper than the next one. From the inside out:
- kernel (
gvn.kernel): the state machines themselves. You describe a machine, the verifier checks it, and a running machine is fed inputs. The kernel also holds decisions (how data picks one of a fixed set of inputs) and the rules for saving an object as plain data and restoring it. It uses only the Python standard library and does no input or output at all. Pages: Machines, Decisions, Durable objects. - harness (
gvn.harness): the actors you build agents from, and what they exchange. The ready-made actors are the agent, workflows, errands, inquiries, approvals, timers and conversations. The harness also defines the ports. Like the kernel, it does no input or output. Pages: from Actors and events through Time below. - runtime (
gvn.runtime): the Governor and the built-in fulfillers, plus recovery after a crash and replay of a recorded run. The only layer that does work, and only through ports. Pages: The Governor, Streaming and observability, Memory, Testing your harness. - adapters (
gvn.adapters): implementations of the ports for vendor models, SQLite and PostgreSQL storage, the system clock, logs and traces. Install the corresponding extra when an adapter needs a third-party library. Guide: Using a vendor model. - shortcuts (
gvn.shortcuts):run_agent, which builds an agent, a Governor, its fulfillers and a journal in one call. Nothing inside gvn imports it. Guide: The short path. - test kit (
gvn.testing): an in-memory fake for every port, so a whole run can be tested offline and fast. Nothing in production code imports it. Page: Testing your harness.
Two sibling packages sit outside the framework, and the framework imports neither:
- gvn-tools (
gvn_tools): ready-made tools (files, shell, git, web, issue trackers, MCP servers), each family with recommended safety rules for the policy. It uses only the harness and the kernel. See Tools. - gvn-domains (
gvn_domains): complete harnesses for real fields (customer service, research, software delivery, finance and more), built only on gvn's public surface. See Domains.
Architecture lists every layer, package and import rule in full, and how each rule is checked.
The map: which page explains which part¶
The pages in this section are ordered from the most fundamental idea to the most derived. Each stands on the pages before it.
| Page | Part of the pictures | The question it answers |
|---|---|---|
| Machines | the actor's machine (kernel) | Which situations exist, and what does each input do in each? |
| Decisions | the actor's machine (kernel) | How does data pick one of a fixed set of inputs, with every case still handled? |
| Durable objects | the actor's data (kernel) | How is an object that hides its state saved and restored exactly? |
| Actors and events | actor, event, request (harness) | How do a machine and its data take events and ask for work? |
| Tools | tools, the toolbox (harness), the tool fulfiller (runtime) | How is a tool named, stored and matched, and how is a run checked against the tools it needs? |
| Sensors | sensors, the sensor toolbox (harness), the sensor fulfiller (runtime) | How does a harness measure after a tool succeeds, show the model the result, and keep an actor from finishing until it is clean? |
| The reference agent | the agent, one actor (harness) | How does the ready-made agent govern model and tool calls? |
| The Governor | Governor, fulfillers, journal (runtime) | Who does the work, records every event and resumes after a crash? |
| Run context | the agent's trusted facts (harness) | Which facts about this run may tools and the policy trust? |
| Streaming and observability | what the Governor reports (runtime) | How do you watch a run, stream text, log and trace? |
| Humans and interruption | the person: approval (harness, runtime) | How does a run wait days for a yes or no, and how is it stopped? |
| Asking a person | the person: questions (harness) | How does a run ask for content and check the answer? |
| Trust: what the model read and who answered | the person and the policy: exposure and answerers (harness, runtime) | How do the policy and the approver know what outside text the model has read, and how is who answered a request checked and recorded? |
| Errands | another actor (harness) | How does code, not a model, make tool calls safely? |
| Workflows | actors made of actors (harness) | How do several actors work as one run? |
| Conversations | another actor (harness) | How does a model talk with a person over many turns? |
| Context management | the agent's and conversation's data (harness), the model fulfiller (runtime) | How does a growing conversation stay within the model's context window, and what happens when it cannot? |
| Memory | a port, its fulfiller and two tools (harness, runtime, adapters) | What outlives a conversation and a run, who may read and write it, and how it differs from the run context and the context window? |
| Time | the clock fulfiller and timers (harness, runtime) | How does a run wait for a time without reading a clock? |
| Workflows in depth | actors made of actors (harness) | Judges, loops, joins, retries, deadlines, compensation, nesting. |
| Harnesses | a packaged job and its launcher (runtime) | How is one job packaged with its entry actor, brief, tools, policy and evaluation, and run by name? |
| Testing your harness | the test kit (runtime, testing) | How do you test all of the above fast and offline? |
Composing a job from smaller jobs¶
A workflow is also an actor. It owns child actors and turns the way each child ended into an input to its own machine. This lets a parent reason about a smaller contract instead of every state inside every child. The meaning of a child's starting data and result is an application contract. Designing a large harness shows how to choose stable boundaries as an application grows, and Interface contracts how to check an implementation against its interface.
What the verifier establishes¶
The verifier checks the declared control graph. Every non-final state needs a route or
fallback for each declared input, and a path to some final state. Every state must be
reachable. In a Moore machine outputs belong to states. In a Mealy machine they belong to
transitions and the fallback. Decisions wired through branch and workflow
stages must have a declared route for each of their possible outcomes.
The verifier works on the control graph. What a model's answer says, whether a tool really undoes an effect, and whether two implementations give compatible application results are checked with schemas (declared shapes that data is checked against), checks in constructors, behavioural contracts and tests. The testing chapter explains how those checks complement the verifier.
Next¶
Start at the bottom of picture 2: Machines.