CanonBall

CanonBall

The lifecycle agents can run and people can trust.

CanonBall is a method for building and operating software with AI agents. People write down what the system must do. Agents build it and produce the evidence. Every release ships all three together.

  • Canonwhat the system promises
  • Buildthe code that keeps the promises
  • Verification Recordthe evidence that it does
  • Releaseall three, shipped together
Each release fixes three things together: what the system promises, the code that keeps those promises, and the evidence that it does.

Why now

Writing software got cheap. Knowing what it does did not.

Agents write faster than people can read.Reviewing every change wastes the agent. Skipping review turns each change into a risk nobody measured.
So the question changed.It used to be "can we build this?". Now it is "what does this change do, and what does the system still promise afterwards?"
The effort moves to verification.Establishing that a promise holds becomes the larger part of the engineering. CanonBall organizes the work around it.

Why the work changed

How work moves

Work moves through seven stations, one milestone at a time.

Related requests are gathered into a milestone. People and agents shape it together, agents build and verify it, an agent reviews it, a person reviews it as well when it is critical, and it is released as a CanonBall. Three practices on the belt, marked 1 to 3, are what make it possible for agents to do most of this work reliably.

Scroll the belt sideways to follow it.

  1. CollectRequests gather into a milestone, and a one-page proposal says what it will change.Agent: ElicitorPerson: Product manager
  2. ShapePeople and agents settle the milestone’s promises, decisions and invariants, how it will be built and how it will be proven, and record it all in the milestone.Agent: ElicitorPerson: Product managerPerson: ArchitectPerson: Verification lead
  3. BuildThe builder writes the code in named tasks and watches what it does through the observability tools.Agent: BuilderPerson: Architectif the team keeps detailed design
  4. VerifyA different agent builds the verification environment and the checks, and shows each check failing before its pass counts.Agent: VerifierPerson: Verification lead
  5. ReviewAn agent reviews every milestone. A person reviews as well only when the change is critical or its blast radius is large.Agent: ReviewerPerson: Owner of what is at riskif critical
  6. ReleaseThe orchestrator, a program, copies the proposed files into spec/, and records a CanonBall: the canon, the build and the Verification Record together. The build it names is then deployed.Program: Orchestrator
  7. OperateThe system runs. Monitors watch what was promised, and what breaks comes back as work.Agent: On-call agentPerson: Operator

Work moves in milestones

Requests are gathered before anything is built, so their promises, decisions and invariants are settled once and an agent receives a complete, consistent specification. Repairs and upkeep that change no promise take the express belt through the same stations.

Read more about Work moves in milestones

Verification environments are engineered

Agents produce most of the evidence, so the environment that produces it is designed with a person and maintained like product code. People can rely on the evidence because they understand how it was obtained.

Read more about Verification environments are engineered

Observability is built for agents

An agent begins each task with no memory of the system. Logs, traces, metrics and state give it the context it needs to build, verify and operate. With them it diagnoses from evidence rather than speculation.

Read more about Observability is built for agents

Walk it, station by station

What gets written down

People steer agents with a few written things.

Each is a short file in plain language, and most are written at the Shape station. Together they bound what an agent may do: it may take any action consistent with them, and nothing that cannot be traced back to one of them.

People write

Vocabulary

The words the team uses, each defined once.

Delivery: the carrier’s delivered scan for the last item of an order. Not the dispatch.

Why it exists. So that a person, an agent and a check all mean the same thing by the same word.

Learn more about Vocabulary

Tenet

Which good thing wins when two conflict.

A person’s review over speed, when money moves.

Why it exists. An agent facing an undecided choice recommends the way the team would, and says which tenet it used.

Learn more about Tenet

Promise

What the system does for someone.

A customer can request a refund within 30 days of delivery.

Why it exists. It is the reason any code exists. Everything else traces back to one.

Learn more about Promise

Invariant

What must always be true.

A refund is never issued twice for the same order.

Why it exists. It keeps a promise safe to make. After an incident, it is how the fix becomes permanent.

Learn more about Invariant

Decision

A choice that could have gone another way, written down.

A refund is approved automatically while the total refunded on the order stays under $100.

Why it exists. Otherwise an agent decides it for you, and may decide differently next time.

Learn more about Decision

Constraint

What is never allowed, whatever the goal.

No payout above $10,000 without review.

Why it exists. Some lines are not the product team’s to move. A constraint has its own owner, with a veto.

Learn more about Constraint

Assumption

A fact about the outside world the system relies on.

The payment gateway pays at most once per request key.

Why it exists. Evidence holds only while the assumption does, so each one is watched in production.

Learn more about Assumption

Example

One worked case of a clause: given, when, then.

Given order 4471 and a refund request with request key K, when the same request, with request key K, is sent a second time and both are reviewed, then one payout is made for order 4471.

Why it exists. Plain sentences hide decisions. People approve examples, and each check is written from one.

Learn more about Example

Machines answer

Evidence

The result of a check that could have failed.

Why it exists. A pass means nothing unless the same check has been seen to fail.

Learn more about Evidence

Verification Record

The status of every clause, computed from evidence.

Why it exists. Nobody gets to write "done". The weakest link is named, not averaged away.

Learn more about Verification Record

A CanonBall

One release: the clauses, the build and the Verification Record, fixed together.

Why it exists. It answers "what does this system promise, and how do you know?" without reading code.

Learn more about A CanonBall

The repository

Every station writes to its own place.

The repository is laid out by the work. Each folder answers one question and has one kind of writer. Follow milestone M2 through it one station at a time, or open any folder.

Follow the milestone
Outside the repository
people own itAGENTS.md

How to work here

The first file an agent reads. The top part is about this repository: its commands, its owners, and who leads which decisions. The appendix is a short summary of CanonBall, the same in every repository that uses it.

### Read first

1. This file.
2. `spec/canon/tenets.md`: which good thing wins when two conflict. Cite a tenet when you recommend a choice.
3. `spec/canon/vocabulary.md`: every domain word, defined once. Use these words and no synonyms.

Read the chapter

The example is a refunds service. Dots show who writes each file: people, agents that build, agents and programs that verify.

Verification engineering

Verification engineering takes the larger share of the effort.

When agents write the code, producing a change is quick and establishing that it is correct is the harder problem. The environments in which promises are checked therefore deserve the same design attention as the product. They are designed with a person who understands them, because evidence is only as credible as the method that produced it.

A verification environment has seven parts

  • BoundaryWhat is under test: the refunds service, at this commit.
  • StimulusHow it is driven: requests through the public interface.
  • WorldWhat surrounds it: a real local store, a fake payment gateway.
  • ProbesWhat can be observed: what the store holds, what the gateway paid.
  • OracleWhat decides pass or fail: a mechanical check, not an opinion.
  • CoverageWhat was exercised, and which injected faults were caught.
  • ControlSeed, clock, a clean start and a clean teardown.
It also states what it cannot show. Real gateway timing, for one. Evidence counts only inside what the environment can show.

A check must fail once before its pass counts

test_same_request_twice_pays_oncepassed, seen to fail
test_retry_after_lost_reply_pays_oncepassed, seen to fail
test_retry_after_lost_reply_on_automatic_path_pays_oncepassed, seen to fail
test_two_concurrent_copies_pay_oncepassed, never seen to fail
Computed status of INV-004Unsupported

The fourth check has never failed, so its pass is not evidence yet.

Verification engineering   Verification environments

Observability

Observability gives agents the context people used to carry.

An experienced engineer debugs with years of knowledge about how the system behaves. An agent begins each task with none of that knowledge, so it depends on what the system can tell it. When every decision is logged with its reason and every request can be traced, an agent can diagnose a fault from the evidence instead of speculating about the code.

Three rules

  • DecisionsEvery decision the system makes is logged with the clause it applied and the inputs it used.
  • TracesOne trace follows each request through every adapter.
  • ToolsAgents have commands to read logs, traces, metrics and state, and to replay a request.
The same tools serve three stations. The builder uses them to see what its code does, the verifier to explain why a check failed, and the on-call agent to diagnose an incident. People read the same signals, so they can check what an agent concluded.

What the on-call agent saw

$ observe/tools/observe decisions --order 5512
REQ-012  refund window
  result        refused
  reason        day 31 of 30
  counted from  dispatch, 2 March
  delivered     4 March

A customer who asked for a refund on day 29 was refused. The decision log shows the cause directly: the window was counted from dispatch, where REQ-012 says delivery.

Observability for agents

A recommended architecture

Keep decisions apart from side effects.

Agents do their best work inside clear structure. CanonBall does not dictate how your code is laid out. It recommends one habit, because it makes evidence cheap: put the logic that decides in one place, and the code that touches the outside world in another.

Inputs come in as dataThe request, the current time, a reading from a sensor. The logic never fetches them itself.
Decision logic: the functional coreGiven this state and this input, what should happen? No database, no network, no clock. The same inputs always give the same answer.
checked for every input
Adapters: the imperative shellPaying out, sending an email, writing a row. Each goes through one named place.
people still review this code
You may already know it.Gary Bernhardt named it functional core, imperative shell. Alistair Cockburn's ports and adapters is the same idea.
Why it suits agents.Logic with no side effects can be tested exhaustively, replayed exactly, and rewritten safely.
What people keep.The interface, the constraints, the adapters, and any design choice they promote to a decision.

An architecture agents can work in

Adoption

Hand over decisions as agents earn them.

Each kind of decision has its own level of automation, so a team can keep architecture or detailed design with a person for as long as it wants and hand over other decisions sooner. A team starts with agents recommending and people deciding, and moves each setting on track record. Review works differently: an agent reviews every change at every setting, and a person reviews as well whenever the policy lists the change as critical.

People decideAgents act
What the system promisesPromises, examples, vocabulary
Agent recommends, a person decides. This stays with people.
What is never allowedConstraints on safety, money, irreversible actions
Agent recommends, a person decides. This stays with people.
Choices a customer would noticeThresholds, policies
Agent recommends, a person decides.
ArchitectureHow the system is divided, where state lives
Agent recommends, a person decides.
Detailed designModule layout, interfaces, retries, data shapes
Agent recommends, a person decides.
Verification designThe environment, what is faked, which failures to simulate
Agent recommends, a person decides.
Decision logicThe functional core: code with no side effects
Agent recommends, a person decides.
Code that touches the outside worldAdapters, permissions
Agent recommends, a person decides.

An illustration. Each team writes its own thresholds in advance. A new model release does not move a setting. Agreement with people over many cases does, and one failure that gets through moves it back. Handing over decisions

Start

Begin from a repository that is already laid out.

The starter repository has the folders, templates and policy pages described here, an AGENTS.md that teaches an agent the method, and tools/canonball, a small program that checks the canon, records evidence, computes the Verification Record and performs releases. Fork it, fill in the top of AGENTS.md, and point your agent at it.

Start a repository

git clone https://github.com/sheshavpd/CanonBall my-system
cd my-system
tools/canonball check
tools/canonball new milestone M1-first-promise

Python 3.11 is the only requirement of the tooling. The system itself can be written in any language.

The starter repository   Its AGENTS.md

Read the worked example

git clone -b refunds-example \
  https://github.com/sheshavpd/CanonBall refunds
cd refunds
git log --oneline     # one commit per station
tools/canonball run && tools/canonball record

The refunds service from the walkthrough, built with the starter. Each station of milestone M2, and the repair of an incident, is one commit, so you can see exactly what each station changes.

The example branch

The guide

Read the rest in 28 short chapters.

This page is the overview. The guide follows one milestone of a refunds service through every station, then takes each concept in turn.

Start with chapter oneJump to the walkthroughGlossary