Designing a large harness¶
This guide shows how to split a harness that does many jobs into parts that can change without touching one another. At the end you have the questions to settle at each boundary, a stage that expresses one in code, and the result of an exercise that replaced a whole build workflow under an unchanged parent.
A harness is the program around a model: its agents, tools, policy and evaluation. More concurrent agents make a runtime work harder. More responsibilities make a harness harder to understand and change. Those are different problems: a 10,000-agent throughput benchmark does not show whether changing a build workflow will require edits throughout its consumers.
This guide is about the second problem. Use objects to own decisions and state, and make their public contracts smaller than their implementations.
- You will be able to: draw the line between one part of a harness and the next, write down what the two sides agree on, and check that a change inside one part does not leak into the others.
- Read first: Actors and events and Workflows. The examples come from the software domain, described later in these docs; this page explains what it uses from it.
- Time: about 15 minutes. This page is mostly design advice, with one short example.
The page reports on a change exercise and gives its result in full, so reading is enough.
The exercise itself is a test suite in gvn's source repository (under
packages/gvn-domains/tests). It ships with the source, so running it takes a checkout of
the repository; the installed packages are enough for everything else on this page.
Where this fits¶
This guide works on the actor box of the quickstart's big picture. A large harness is rarely one actor. It is a workflow: an actor whose states run other actors, its children, in stages. The workflow is the parent; each child may itself be a workflow with children of its own. The workflow's plan says, for each stage, how to build its child and how each way the child can end becomes the parent's next input. The Governor and its ports (model, journal, output, clock, tools) stay outside this tree of actors and serve all of them.
flowchart TB
governor["<b>Governor</b> and its ports<br/>model · tools · journal · output · clock"]
subgraph tree ["The actor tree"]
parent["<b>Parent workflow</b><br/>its machine and plan"]
child["<b>Child</b><br/>for example a build workflow"]
grandchild["Its own children<br/>agents, reviewers, errands"]
parent -- "stage: starts the child" --> child
child -- "final state" --> parent
child --> grandchild
end
governor -- "events" --> tree
tree -- "requests" --> governor
The question this page answers is what the arrow between a parent and a child should carry, so that the inside of the child can change without the parent noticing.
Start with a job boundary¶
Suppose a release workflow needs a feature built for one repository. Its child may plan,
write code, run checks repeatedly and ask several reviewers. The parent should need a
request such as “build this task in this repository” and an agreed ending such as
delivered, rejected or failed.
flowchart TD
P["Parent: coordinate delivery"] -->|"Brief: task and repository"| B["Public build boundary"]
B -->|"Agreed terminal result"| P
subgraph Private["Child implementation"]
B --> Plan["Plan"]
Plan --> Implement["Implement"]
Implement --> Check["Run checks"]
Check -->|"retry within bound"| Implement
Check --> Review["Reviewer group"]
Review --> Deliver["Open change request"]
end
These arrows show responsibilities and data flow. The child's complete state diagram is separate. The parent does not need to see the loop count or each reviewer's prompt to ask for a build.
Choose a child boundary when it owns a coherent job, has a meaningful input and result, and can be tested separately. A stage does not need a new wrapper class merely because it exists. Introduce a boundary when it keeps implementation knowledge out of consumers.
Agree on the contract before the plan¶
Actor, the base class of every actor, supplies how a child is run: it receives events,
asks for work and ends in a final state with an outcome. Your application supplies the
meaning: what the brief (the starting input) holds, what each final state means, and
what the result data promises. Write those down before choosing internal states:
| Part | Agreement to make | What it protects |
|---|---|---|
| Starting input | Required fields, constraints and the event that carries them | A replacement receives the same job. |
| Terminal states | Which states mean success, refusal and failure | A parent routes every possible ending. |
| Result | Which fields each ending promises, and who validates them | A successful ending contains what its consumer actually needs. |
| Effects | What the child may change, where approval is needed, and how repeats are handled | A replacement cannot silently widen its authority. |
| Recovery | What code/version restores existing runs, and which migrations are supported | Deployment does not silently reinterpret parked work. |
An explicit schema (a gvn.kernel.schema object that checks a value's shape) can validate a
boundary record. A result reader, a small class of yours over the child's outcome, can
expose operations such as “which change request was opened?” while hiding the location of
that fact in the child's workflow history (the record of which stages ran and how each
child ended). Put that reader next to the child boundary, and keep the mapping
from internal results there. If every parent walks history and names internal stages,
those parents depend on the child's implementation despite using public getters.
The framework's Report (a reader over a workflow's outcome) helps read workflow history;
it is not a domain result contract. Likewise, Outcome (how an actor ended: its final state
and a payload) validates that its payload is JSON, not that a delivered build has
produced a usable artifact. Validate required meaning at the boundary where it becomes
an application guarantee.
Express the child boundary in a stage¶
The software domain ships NodeBuild, a workflow that builds a
feature in a Node.js repository. It accepts a starting payload with task and repository,
and ends in delivered, rejected or failed. A parent stage can depend on that vocabulary
without depending on planning, verifying or reviewing inside the build.
A stage that runs one child is a Host. Composition code is the code that picks the
classes and assembles the stages when the harness is built. The parameters here have
separate jobs:
build_classselects the implementation in composition code. It becomes the Host'sactor_class, whichHostalso uses when restoring the child after a crash.makereceives the name (the child's address in the actor tree) chosen by the parent and constructs that child. It also receives the memo, a read-only view of the parent's data.startadapts the parent's starting input (memo.input()) into the child'sstartedevent. In this example their brief shapes agree, so the whole input can pass through.routestranslates child endings to parent inputs. It must cover every final state of the selected child's definition.
This runnable construction uses public interfaces and creates no model or tool calls:
from gvn.harness.events import Event
from gvn.harness.workflow import Host, Workflow
from gvn_domains.software.web.node import NodeBuild
def build_stage(build_class: type[Workflow]) -> Host:
return Host(
actor_class=build_class,
make=lambda name, memo: build_class(name=name),
start=lambda memo: Event(name="started", payload=memo.input()),
routes={"delivered": "built", "rejected": "declined", "failed": "broken"},
)
building = build_stage(build_class=NodeBuild)
A parent Plan (the object that pairs a workflow's machine with its stages) must route
built, declined and broken from its building state. It also declares, with tools=,
every tool the child and anything beneath it may use, so the runtime checks its toolbox
before the run starts (Tools); the software
domain exports a feature build's tools as gvn_domains.software.build.TOOLS, so the parent
passes those objects instead of listing the child's tools itself.
Changing build_class is enough for construction only when its final vocabulary matches;
preserving the brief, effects and result meaning still needs the behavioral tests below.
Keep state ownership distinct from construction¶
A workflow instance owns its machine position, active children and recorded results. A plan describes how to create children and route their endings. Runtime ports (the objects through which gvn reaches the outside world) belong to the Governor and its fulfillers, outside the actor tree that the journal saves.
| Belongs to | Examples | How others access it |
|---|---|---|
| Child run | Transcript, retry count, reviewer actors | Through the child's supported behavior and agreed result. |
| Parent run | Starting brief, parent control state, finished child results | Through the parent actor and its memo/result readers. |
| Composition code | Child class, stage recipes, routing decisions | Supplied when the harness is built; recovery must locate compatible code. |
| Runtime | Model, journal, output, clock, effectful tools | Injected through ports, then used to fulfil requests. |
Pass configuration into the object that owns the decision it configures. Avoid making
every stage read a shared mutable settings record. The software domain's Stack (the
commands and conventions of one technology stack) and feature_plan(stack) (which builds a
feature workflow's plan for a given stack) show shared construction across technology stacks
without coupling the stack modules to one another.
Plain data at an input/output boundary is useful. The goal is that one object owns the live state and enforces its invariants; wrapping a dictionary in getters without reducing what callers must know does not achieve that goal.
Tools belong to the part that owns them¶
Every tool has a short name, which the model sees, and an identity, its namespace (by
default the module that defines its class), a dot and its short name, which gvn stores and
matches on (Tools). In a
large system, let the namespace say which part owns the tool: define each tool in a module
of that part (shop.payments.refund, ops.releases.deploy), so two parts may each have a
look_up and one deployment's toolbox may hold both. Choose namespaces once: identities are
stored in the journal, so renaming a namespace renames every stored reference to the tool
(For a tool's author). A part exports its tools as
objects, and the code that refers to them, a parent's plan, a policy, an evaluation check,
imports those objects rather than repeating names.
Make one change and inspect its reach¶
Use a concrete change exercise before adding more framework abstractions. For the software build, reasonable changes include adding an evaluation-writing stage, renaming internal states, or changing the review fan-out and retry limit.
Before editing, list what must stay stable: the starting brief, terminal vocabulary, required result meaning, effect permissions and parent behavior. Then make the change inside the child and its composition code. Check whether the parent can remain unchanged.
| Change | Expected place for edits | Evidence to collect |
|---|---|---|
| Different check commands or reviewer roles | Stack/profile and child tests | Same parent tests pass for both configurations. |
| New internal stage or revised loop | Child machine, plan and tests | Parent routes and input/result handling stay unchanged. |
| Different result representation | Child-owned result reader or boundary adapter | Consumers still obtain the agreed domain answer. |
| New required brief/result field | Contract and affected consumers | Deliberate incompatible change or an explicit adapter. |
| New behavior while old runs are parked | Version selection and migration/recovery tests | Old runs restore under compatible code or are explicitly refused. |
Do not count an unchanged parent file alone as proof. If it still runs but receives an incomplete result, the change escaped through a weak contract. Include negative tests for a child that reaches the expected final state with invalid result data.
The repository's change exercise¶
The executable exercise is application code in
packages/gvn-domains/tests/dom_change_isolation.py, tested by
packages/gvn-domains/tests/test_dom_change_isolation.py. It packages the real
FeatureBuild (the software domain's packaging of a feature-build workflow such as
NodeBuild together with the workspace and change-request ports it needs) inside a release
desk. The same parent builds a change, then hosts an
Approval asking a person to release it. The same client answers pending approvals by
their public requests, rather than by hard-coded child addresses.
| Boundary or implementation | Before | After |
|---|---|---|
| Starting brief | task, repository |
Same validated brief |
| Parent control definition | PARENT_DEFINITION |
Same object |
| Parent's child terminal contract | delivered, rejected, failed |
Same vocabulary |
| Build implementation | Shipped NodeBuild |
ReworkedBuild wrapping a preflight errand and a nested ExpandedBuild |
| Evaluation writing | No separate stage | Added before implementation |
| Reviewers | Two | Three |
| Implementation attempts | Two | Three |
| Parent routing and approval client | Build, then ask to release | Same code |
Only composition code selects the child implementation. The parent does not inspect the build's stage names or history. The exercise compares final application behavior and workspace/change-request effects, and tests approvals, reviewer objections, retries, interrupt/resume while the parent waits for release approval, and crash recovery within each compatible implementation. The added evaluation file and preflight command are intentional additional effects; the delivered application code and opened change request remain the same.
What it showed: with the build replaced by a larger one (a new stage, a third reviewer, a third attempt, a nested workflow and a preflight errand), the release desk ran on the same definition object, the same routing and the same approval client, delivered the same application code and opened the same change request. The suite has 25 tests, including 116 crash/recovery executions: before and after each append in the original's 24-event run and the replacement's 34-event run, using fake ports. All of them pass.
To run it yourself, from the root of a checkout of the repository:
The exercise also records the boundary's rules as tests: incompatible terminal names are refused; reading a child's internal stage history breaks after the change; restoring a changed active child graph is refused; and a changed stage factory with the same machine fingerprint (the short code computed from a definition) is accepted and produces different subsequent instructions. The fingerprint covers the control graph, so a change to a factory's behavior needs its own tests and, for parked runs, its own migration. Validating the result payload of a child is the job of your boundary, as described above.
Test the boundary at several levels¶
- Test the input and result rules directly, including missing fields, wrong types and each terminal state.
- Run the same parent scenarios against both child implementations using fake ports. Check domain results and permitted effects, not only the final state name.
- Exercise failures, refusals, approvals, review vetoes and bounded retries. A replacement must preserve the behavior its consumers depend on in those cases too.
- Crash and restore runs at recorded boundaries using each compatible implementation. Check pending requests and repeated-effect handling as well as the final outcome.
- Separately test the supported deployment transition from old code to new code. Reject an unsupported saved state instead of presenting a different interpretation as recovery.
The testing tools supply crash matrices (a run crashed and restored at every recorded point) and reusable port contracts (shared tests any port implementation must pass). Interface contracts summarizes the runtime obligations that every child must preserve.
Replacement is different from migration¶
A new run can use a changed child if it preserves the application contract. An existing run has more history: machine positions, saved child data, recorded model answers and pending requests. Those may refer to the old implementation.
Definition fingerprints reject a saved machine position on a different graph. They cover the control graph; callbacks, prompts, decisions and external effects are covered by your behavioral tests, so the same graph with different callback behavior needs those tests to pass before it counts as compatible. Versioned stored forms support explicit upgrades, and writing an upgrade is a separate decision from changing a plan. See Replay and evaluation.
The verifier establishes properties of the declared control graph. Substitutability of a child and safe behavioral migration are contracts with their own evidence, alongside performance measurements from the scale benchmark.
Recap¶
- Draw a boundary around a coherent job with a meaningful input and result, and agree on the brief, the final states, the result, the effects and recovery before choosing internal states.
- A
Hoststage expresses the boundary:routesnames the child's endings, and composition code picks the child class. - Each part owns its state and its tools; parents read a child through its agreed result, not through its history.
- The change exercise replaced a build workflow under an unchanged parent: same delivered code, same change request, recovery at every recorded point.
- Replacing a child for new runs and migrating parked runs are separate decisions, each with its own tests.
Next: to build the stages inside a part, read Fan-out over items, with retries and Different kinds of child in one stage; to crash and restore a run at every recorded point in your own tests, read Testing your harness.