The Run Contract and Baseline
Register the fixture, model, configuration, budget and independent acceptance oracle before a run.
Two runs of the same Repo Scout question come back with different verdicts. Before anyone can say why, they have to be able to say what was different, and for most agent systems that question has no answer. The prompt is assembled at run time. The runtime has defaults nobody chose. The tools the model saw are whatever happened to be registered. The test that decided “pass” was written after someone looked at the output. This chapter builds the object that makes the question answerable: a run contract, registered before the run starts, together with a baseline that differs from a treatment by exactly one named thing.
Evidence status. Draft manuscript. The research milestone HARNESS-RESEARCH-01 has completed with a CONDITIONAL GO for the offline Project 01 foundation only. That is not full-book Gate A acceptance. The Project 01 implementation is a corrective candidate independently re-reviewed and returned for correction (REJECT, 2026-11-23). It is not accepted. Implementation findings quoted here are OBSERVED in named review documents and carry the Implemented category only within the offline, scripted-provider scope those documents state. The run contract below (§3.8) is the frozen offline registration with real digests from the lab. No live model run, comparative measurement or security boundary is claimed. EXPERIMENT PENDING for the formal comparisons (P01-E, P01-F) and Gate C.
3.1 The configuration you think you ran
The first independent review of the Project 01 lab found the following
(docs/research/HARNESS-PROJECT-01-REVIEW/REVIEW.md, findings P01R-09 and
P01R-10; OBSERVED):
- The design called for idle cache warming to be off. The effective
setting was
idle. - The design called for provider retries to be zero. The provider
maxRetriesfield was unset. - The design called for a network-disabled model runtime. The runtime’s network field was true.
- The design called for no ambient paths in the model-visible prompt. The assembled prompt contained the absolute path of a temporary directory.
None of these defects broke a test. The offline suite passed 56 of 56 at the time. Each one would still have changed what a later live comparison measured. Retries alter cost and latency. Cache warming alters request timing. A machine-specific path leaks into what the model reads and differs between machines. The authors had written down the configuration they intended to run. Nothing had checked that it was the configuration that actually ran.
This is the general problem. An agent run sits on several layers of
defaults: provider, runtime, resource discovery, tool registration and
operating environment. Each layer has values the author never set. The
Pi 1.6.0 audit records some of these for the runtime alone: compaction and
retry are enabled by default, the retry maximum is three, and cache warming
defaults to idle (R02-PI.md C13; DOCUMENTED/OBSERVED; Established for
the inspected artifact). The same audit finds that resource-suppression
flags on their own do not exclude every instruction-discovery or
package-resolution path (C05/C06), and that +name tool modifiers are not a
restrictive allowlist (C02). A run that does not record and assert its
effective configuration cannot be compared with anything.
3.2 Deriving the contract: what else could explain the result?
The usual way to present a run manifest is as a list of fields. We derive the fields instead from one question. If this run and another run disagree, what could have caused the disagreement? Every plausible cause that the contract does not pin is a confound. Each confound must either be fixed in advance or recorded so that it can be compared later.
| Possible cause of a different result | Contract element that pins or records it |
|---|---|
| A different task or wording | Task ID, exact question text, question ID |
| Different data | Fixture identity: per-file content digests and a fixture digest binding paths and contents |
| A different model-visible interface | Exact system-prompt bytes, tool names, tool schemas, tool order, history policy |
| A different model or sampling | Provider and model identity, snapshot if available, parameters, seed field if the provider honours one |
| Different runtime behaviour | Effective runtime settings (retry, compaction, cache warming, network), asserted before the first request |
| Ambient influence | Declared resource loader, declared environment and configuration directories, enumerated startup read set |
| A different amount of effort | Budgets: tool calls, bytes, model requests, wall clock, and spend where metered |
| A different definition of success | The acceptance oracle, its version and its digest, frozen and held outside model-visible data |
| A different reading of the results | Endpoints, exclusions, invalid-run rules and the analysis method, registered before treatment results are viewed |
The last two rows are the ones most often missing. If the oracle is written
after the output has been seen, it measures how well the author can
describe the output, not whether the task was done. If exclusion rules are
decided after seeing which runs failed, the author can rescue a treatment.
The Project 01 experiment plan therefore requires both to be frozen in a
manifest before any model run (PROJECT-01-EXPERIMENT-PLAN.md,
“Registration before model runs”, items 1–7; PROPOSED, reviewed
candidate protocol, not yet a registered live study).
There are three things the contract cannot do, and they should be said
plainly. Recording a seed does not make a provider’s output reproducible.
Matched seeds do not guarantee identical model responses (CLAIM-LEDGER.md
H01-C13, from R05; DOCUMENTED; Established within the cited sources'
scope). A hash binds bytes, not truth: it shows that a record has not
drifted, and it says nothing about whether the record was honestly
produced. A budget written in the contract is not automatically enforced.
Post-response token accounting can overshoot, and the Pi adapter alone
supplies no hard spend cap (R02-PI.md, unsupported seams). The contract
registers the limit and how it is enforced, including the ways enforcement
can fall short.
3.3 Declared, effective and bound
The opening example separates three properties of every contract field, and an implementation can fail at each one separately.
- Declared. The value is written in the contract.
- Effective. The running system actually used that value, and the host checked this before the first model request. It did not infer it from the code path it expected to run.
- Bound. Every later consumer of the evidence checks the run against the value: the supervisor, the replay tool and the evaluator. A run whose recorded behaviour contradicts its contract is rejected, not reported.
The first corrective freeze of Project 01 shows the third failure clearly.
The adapter had been fixed. Its effective settings now recorded cache
warming off, compaction and retry disabled, provider retries zero, the
runtime network field false, and a declared logical working directory in
place of a real temporary path (INDEPENDENT-REREVIEW.md; OBSERVED).
The replay verifier, however, still accepted bundles that contradicted the
contract. The re-reviewer took real captured runs, changed them, recomputed
every ordinary digest and replayed them. Four changes were each accepted as
VERIFIED_CORRECT / COMPLETE with no detections: the envelope’s allowed
tools set to empty while real tool calls remained; the provider’s user
question replaced; the effective-configuration record deleted; and the
network field set back to true (finding RER-03; OBSERVED). The contract
had been declared and made effective, but it was not bound. In effect,
replay had checked the shape of the record and not whether it kept the
promises the contract made.
The second corrective freeze claimed to close RER-03. Independent re-review (HARNESS-PROJECT-01-REVIEW-02, verdict REJECT, 2026-11-23) re-ran the original RER replay attacks and fresh current-adapter substitutions: RER-03 is CORRECTED for the tested substitutions, while RER-02 (replay reconciliation) and RER-04 (failed-receipt coherence) remain open with fresh blocking forgeries. The candidate is returned for correction; nothing in Project 01 is accepted.
3.4 A run is a small state machine
So far the contract has been a list of what is held constant. It also specifies what may happen: which states a run can occupy, which transitions between them are permitted, who may trigger each transition, and what record each transition must leave.
This section introduces the book’s central architectural hypothesis in its smallest form. It is labelled PROPOSED. The book investigates it; it does not assume it.
Hypothesis H-ST. A harness is a programmable system that directs intelligence through transitions between states. The model supplies reasoning where reasoning is needed. The harness decides which transitions are eligible, which are authorized, how each is verified and recorded, and what survives.
Here is the hypothesis applied to a single Repo Scout attempt. The states
and rules come from the reviewed offline contract
(OFFLINE-IMPLEMENTATION-CONTRACT.md §4; PROPOSED design, implemented
in the uncommitted candidate, not accepted).
| From | To | Trigger | Who decides | Record that must exist afterwards |
|---|---|---|---|---|
| — | ADMITTED | Contract validated: fixture admitted, budgets and oracle registered | Host (deterministic) | Admission record; a precreated attempt envelope |
| ADMITTED | STARTING | Worker launched | Supervisor (deterministic) | Launch record |
| STARTING | RUNNING | Worker reports effective configuration, and the host asserts it matches the contract | Host check (deterministic) | Effective-configuration record |
| RUNNING | RUNNING | Model proposes a tool call; tool returns a result | Model proposes; tool handler admits or rejects (deterministic) | Raw events for request, tool start and tool result |
| RUNNING | STOP_REQUESTED | Budget, deadline or cancellation | Host or supervisor (deterministic) | Stop reason, kept separate from the model’s own stop reason |
| RUNNING | FINALIZING | SDK settlement observed | Pi signal, then host check | Settlement event |
| STOP_REQUESTED | FINALIZING | Abort acknowledged and runtime idle | Host (deterministic) | Abort record |
| FINALIZING | TERMINAL | Drained, reconciled, evaluated and persisted | Supervisor (deterministic) | Exactly one terminal record |
| STARTING / RUNNING | TERMINAL | Preparation rejected, worker crash, or kill | Supervisor (deterministic) | Incomplete terminal record; cleanup confirmed or STOP_UNCONFIRMED |
Look at the “Who decides” column. Only one transition family involves the
model at all: the self-loop inside RUNNING. There the model proposes
the next action, and even then a deterministic tool handler decides whether
the proposal is admitted. Every other edge belongs to the harness. This is
the narrow, testable sense of the claim that the harness is what engineers
build around the intelligence. The model is needed in one state. The
contract defines the edges.
The table also states an invariant: a run admits exactly one terminal
record, and late messages are kept as anomalies that cannot overwrite it.
Invariants like this are where state-machine framing pays for itself,
because a violation can be found mechanically. The first corrective freeze
violated this one. The re-reviewer forced a failure while
supervisor-receipt.json was being written. The return channel correctly
reported RECORDING_FAILURE, yet the parent event log held two
supervisor.terminal events: first “completed/verified”, then “failed”
(RER-04; OBSERVED). The code had marked success as terminal before the
persistence step that success depended on. The test suite had passed. Once
the invariant was written down, the defect could be found.
A transition is not a model call. A harness that sends every edge through the model (“ask the agent whether the run is finished”) has handed its control plane to the component it was meant to govern. Chapter 14 develops typed transitions and deterministic gates. Here the point is only that the run contract must list the transitions and their owners. Leaving them implicit in the agent loop is not acceptable.
3.5 The oracle belongs to the contract
An acceptance oracle is the check that decides whether the required result was produced. It is independent of the agent’s own account. It is registered with the contract because otherwise it is not independent.
The Project 01 design treats the oracle as part of the run’s structure, not
as a scoring script written afterwards (OFFLINE-IMPLEMENTATION-CONTRACT.md
§3; PROPOSED):
- It holds the expected finite fact values, the acceptable source ranges, explicitly excluded assertions and, for questions with no answer, the exact finite scope that was searched.
- It sits outside the fixture manifest and outside every tool-accessible path. The candidate keeps it in a separate module that tools and adapters never import.
- A result passes only if both the fact check and the evidence-locus check pass. A correct value with an irrelevant citation fails. An extra unsupported assertion fails.
- Negative cases are built in: conflicting text, a deliberately unanswerable question, malformed output, and an “always abstain” policy that must not score well.
The oracle’s reach must be stated as part of the contract. The offline phase checks exact constructed facts, not general semantic entailment. A citation whose line range contains the right string does not prove that the text supports the claim (P01R-15, a confirmed limitation). Before any semantic or live study, a human must accept the fixture’s ambiguities and answer adjudications. The agent never authors or grades its own oracle.
3.6 Budgets: declared limits and their leaks
A budget in a contract is three things at once: a limit, a place where the limit is enforced, and a record of what was actually spent. Writing down the first is not the same as having the other two.
The original Project 01 review found that call and byte budgets could be
bypassed or undercounted (P01R-11; OBSERVED). The re-review of the
first freeze then confirmed that invalid invocations are now charged
against the call budget (fifty invalid calls cost fifty calls, and the next
list request fails), and that a read budget covering only the body text no
longer releases a larger response (OBSERVED, INDEPENDENT-REREVIEW.md).
The same re-review also found that a worker’s summary could misstate what
it spent and still be accepted. A summary reporting 0.5 model calls passed
validation, because the check required finite non-negative numbers rather
than integers. A summary reporting zero tool bytes passed against an actual
response trace of 3,227 bytes, because the host copied the summary instead
of reconciling it with the events (RER-02; OBSERVED).
Two rules follow, and the book uses both from now on:
- Spend is derived, not reported. The authoritative usage figure is reconstructed from independently recorded events. A component’s account of its own spend is a claim to be checked against them.
- Unknown is not zero. When usage cannot be determined, for example
for a worker that crashed or a provider that did not report, the record
says
nulland the analysis treats it as missing. The candidate now records unknown usage on failed children as null (labREADME.md; implementer claim pending re-review). Independent re-review confirms the live-side null-usage behaviour but finds replay-side reconciliation NOT CLOSED (fakeoutcome.usageand evaluation-detail forgeries replay as matching; REVIEW-02 §4, RER-02).
3.7 What a baseline is, and what it is not
A baseline is not “the system without a harness.” Pi is already a minimal harness, and a host that runs no checks is not a neutral control. It is just an unexamined configuration. A baseline is the reference configuration that differs from the treatment by exactly one named mechanism in an elementary ablation, with other contract conditions held equal. Registered factorial designs instead declare factors, levels, main effects and interactions; whole-system comparisons declare the bundle and contrasts without attributing its gain to one hook (Chapter 18 §18.3/§18.8). These are distinct legitimate designs.
This definition rules out a good deal. If the treatment changes the prompt and adds tracing, there are two treatments and the comparison cannot separate them. If the treatment arm gets a larger token budget, any gain may be bought spend, not better design. This is the budget illusion from Chapter 1. Matched total budgets become mandatory for multi-agent comparisons from Project 08. If the treatment arm runs on a different day against a provider with different load, time is now a variable, and the contract must record date, time and provider error behaviour so that this can at least be detected.
Project 01’s first comparison is deliberately unglamorous. The treatment is
instrumentation itself (PROJECT-01-EXPERIMENT-PLAN.md; PROPOSED):
| Arm | Task-facing configuration | What differs |
|---|---|---|
| A — baseline | Explicit Pi host, fixed fixture tools, fixed model and prompts | Common minimal invocation and outcome accounting |
| B — instrumented | Identical task-facing configuration | Adds raw-event capture and normalized trace artifacts |
| C — fault control | Offline recorded or constructed events only | Known observations removed, duplicated, reordered or truncated |
Why measure the measuring system first? Every later mechanism in the book will be judged through traces. If adding the tracer changes what the model sees (an extra line in the prompt, a different tool ordering, a slower response that changes timeouts), then every later “improvement” is mixed up with the observation apparatus. Arm C is not a model experiment. It is a deterministic check that the collector notices when evidence is damaged (Chapter 4). Arm A is also not “unobserved”: it carries the common accounting that any comparison needs, and the plan requires that accounting and its cost to be reported.
The experimental unit needs the same care. The plan’s unit is a task-instance/run pair, grouped by fixture and task. Twenty repetitions of one question on one repository are not twenty independent repositories (H01-C13). They tell you about variance on that task, not about coverage of tasks. The analysis must be paired and grouped, report discordant pairs, and must not present a single aggregate percentage as if it were a property of the mechanism. A non-significant difference between A and B does not show that the two are equivalent.
3.8 Worked example: registering task T2
The candidate fixture is a tiny synthetic repository (repo-scout-v1) of
six authored text files: a retry configuration, a scheduler, a worker, a
test, an API note and a decoy scratch file. Task T2 asks: “What
configuration key controls the maximum number of attempts?” The oracle’s
expected fact is max_attempts, at line 3 of the file with ID
retry-config (examples/pi-harness-lab/src/oracle-data.ts, working-tree
candidate; Implemented-candidate, not accepted).
Below is the run contract for one attempt at T2 — the frozen offline
registration with real digests computed from the lab fixture
(repo-scout-v1 fixture digest
c1a23100463dcaa9aa2f68ee0778d182139bf28624d6cd0ad6b21c2ed02457ad;
retry-config content digest
61f053f5330410b36945310a1a99a1d16e0d48dff3ce1e54a55f1fbd7621c340;
oracle-entries digest
ce21aaa263cab9a3119df4cb7dc1622e82c5532986e71125333d74185e4843c7).
Model, provider and spend-envelope values stay <registered>: choosing
them is part of registration, and no live registration exists. Field
names follow the offline contract and the experiment plan’s registration
list.
// Frozen offline registration (digests above); model/provider/spend stay
// <registered> until a live registration exists. Not a Pi API.
{
"contractVersion": "run-contract-v1",
"task": { "taskId": "T2-config-key", "questionId": "T2-config-key",
"question": "What configuration key controls the maximum number of attempts?" },
"fixture": { "fixtureId": "repo-scout-v1", "fixtureSha256": "c1a23100463dcaa9aa2f68ee0778d182139bf28624d6cd0ad6b21c2ed02457ad",
"limits": { "maxFiles": 16, "maxAdmittedTextBytes": 65536 } },
"interface": {
"systemPromptSha256": "<sha256 of exact bytes>",
"tools": ["fixture_list", "fixture_read"], // literal names; no +modifiers; candidate wrapper also filters by the task's admitted list, and a non-admitted call returns `INVALID_ARGUMENTS` (see Ch 5 §5.4)
"toolSchemaSha256": "<sha256>",
"logicalCwd": "<declared constant, not a real path>"
},
"runtime": {
"pi": "1.6.0 (exact artifact + lockfile digest)",
"assertBeforeFirstRequest": {
"compaction": "off", "retry.enabled": false,
"retry.provider.maxRetries": 0, "cacheWarming": "off",
"modelNetwork": false
}
},
"model": { "provider": "<registered>", "model": "<registered>",
"params": "<registered>", "seedHonoured": "UNKNOWN" },
"budget": { "maxToolCalls": "<registered>", "maxToolBytes": "<registered>",
"maxModelRequests": "<registered>", "wallClockMs": "<registered>",
"spend": "<registered envelope; enforcement limits stated>" },
"oracle": { "oracleSha256": "ce21aaa263cab9a3119df4cb7dc1622e82c5532986e71125333d74185e4843c7", "visibility": "never model-visible" },
"arm": "A-baseline | B-instrumented",
"analysis":{ "unit": "task-instance/run pair, grouped by task",
"invalidRunRules": "<frozen, arm-blind>" }
}
Walk the attempt through the transition table in §3.4.
- Admission. The host loads the six files and normalizes line
endings. It rejects a byte-order mark or a lone carriage return, hashes
each file, and computes the fixture digest over the sorted rows of
(fileId, displayPath, byteLength, contentSha256). If any file breaks a
rule, for example a path segment of
.., a backslash, or more than 16 files, admission fails. The attempt goes straight toTERMINALwith an incomplete record. The model is never called. - Start. The worker reports its effective settings. If cache warming
reads
idle, or the provider retry count is missing, the host refuses theSTARTING → RUNNINGtransition. This is the exact defect from §3.1, now caught by a transition guard instead of a reviewer. - Run. The model proposes
fixture_list, thenfixture_readforretry-configlines 1–4. Each proposal is checked against the contract: the tool name must be literal, the range must be within the file and within 100 lines and 8 KiB, and the call budget must not be exhausted. Each check is a deterministic gate on the self-loop. - Settle and finalize. Settlement is observed. The host waits for idle, reconciles canonical messages, drains the event queue and evaluates the answer against the oracle it registered in step 1. Only then is a single terminal record written.
Now suppose arm B’s T2 attempt fails and arm A’s succeeds. Because of the contract, the candidate explanations can be listed: a different model response on identical inputs (stochastic variation); a difference in model-visible requests (a contract violation, which offline qualification must exclude); a collector-induced crash (scored as a failure of arm B, not excluded); or an evaluator defect (which invalidates the block only under frozen, arm-blind rules). Without the contract, the honest answer to “why did it fail?” would be “we don’t know.”
3.9 Failure modes
- Declared but not effective. The manifest says retries are off; the
runtime default says three. Detection: assert effective settings at the
STARTING → RUNNINGguard. (Observed: P01R-09.) - Effective but not bound. The adapter runs correctly, but replay accepts records that contradict the contract. Detection: adversarial replay with every ordinary hash recomputed. (Observed: RER-03.)
- Oracle written after the fact. Any oracle edited after the treatment outcomes are seen. Detection: oracle digest frozen in the registration, and development failures kept out of the confirmatory oracle.
- Two treatments disguised as one. The instrumented arm also changes a prompt line. Detection: compare model-visible requests between arms at the model-request boundary, including tool-result turns and not only the first prompt.
- Labels that outrun evidence. The original lab reported “6/6”. That meant six task contracts exercised by hardcoded scripts, not six model successes (P01R-19; OBSERVED, confirmed limitation). A contract states what a run is: scripted, simulated or live. Its result labels must keep that distinction.
- Repetition mistaken for coverage. Many runs on one task reported as a success rate for the mechanism. Detection: the registered unit of analysis is part of the contract.
3.10 Is a state machine enough? A proposed representation study
H-ST raises a design question that this book prefers to answer with evidence rather than taste. Several sophisticated agent systems seem to drift towards explicit graphs of states, dependencies and evidence. Is that because the graph representation does something, or because it is the general shape of any non-trivial record?
For the single-attempt lifecycle above, the honest prior is that a state machine is already the graph. There are no branches worth the name, no joins, and no dependencies between runs. A graph representation should earn its complexity only where those appear: multi-step workflows with retries and human gates (Project 06), parallel work that must be merged (Project 08), and evidence that must be traced across runs (Projects 09–10).
We therefore register a candidate study, specified in full in Chapter 14 §14.6, and do not claim a result here. EXPERIMENT PENDING.
| Element | Design |
|---|---|
| Arms | (1) linear scripted workflow; (2) state machine backed by durable records; (3) explicit graph of states, dependencies and evidence edges |
| Held constant | Model, tasks, tool surface, permissions, budgets, oracle, fault schedule |
| Endpoints | Correct recovery after injected faults; verified task completion; ability to trace every terminal outcome to supporting evidence; engineering change cost to add one new state or gate; runtime and storage overhead |
| Prediction (to freeze before treatment) | Arms 2 and 3 tie on single-run recovery and traceability; arm 3 is cheaper to extend only once cross-step dependencies exist; arm 1 fails recovery |
| Falsifier | Arm 3 shows no advantage on any endpoint once dependencies exist, or its advantage disappears under matched engineering effort |
Either outcome is useful. If the graph wins where predicted, the intuition has evidence behind it. If it does not, we have found the boundary of the intuition. A graph is a way of modelling the system. Whether an implementation needs a graph database is a separate engineering question, and the default answer is no.
3.11 What you can build and test now
Without any model access — all five now exist in the lab, cited to their evidence:
- The contract schema with the fields in §3.2, including the frozen
offline registration above (
host.tsadmission;contracts.ts). - The startup guard comparing effective runtime settings with the
contract and refusing on mismatch, including
cacheWarming: "idle"(supervisor effective-settings assertion; P01R-09/10 OBSERVED). - The transition table as data (§3.4) with the single-terminal-record invariant, tested under injected persistence failure (supervisor + D14 gates; RER-04 shape).
- The replay check recomputing every ordinary digest after changing the allowed tools, the question or the effective settings, and rejecting every change (witness + replay suites; RER-03 shape).
- Model-visible request comparison of arms A and B through the scripted provider, including tool-result turns (pi-adapter effective settings and prompt capture; H1 shape).
Each of these is a test of the contract, not of the model. None of them shows that a mechanism improves anything. The remaining gap is binding: replay must reject every contract contradiction (RER-02 open), and the live comparison that would exercise the whole contract has not run.
3.12 What remains unverified
- Independent re-review is complete (REVIEW-02, REJECT): RER-01 and RER-03 corrected; RER-02 NOT CLOSED; RER-04 PARTIAL. The contract is declared and largely effective but not bound; P01-E, P01-F and Gate C remain pending.
- Provider and model selection, prices, monetary envelope, sample sizes, overhead tolerance and the stopping rule. These are open registration fields, so no live registration exists. H3’s overhead tolerance needs at least a proposed magnitude before registration (cf. Ch 04 §4.7).
- Human acceptance of the fixture’s ambiguities and of the oracle’s answers.
- Whether the effective-configuration checks cover native or library network and file access, rather than only the paths a JavaScript-level monitor can see (offline contract §1; the coverage limit must be reported).
- Every claim in §3.10. That study is registered as a candidate only.
EXPERIMENT PENDING. This chapter reports implementation review findings within their stated offline scope, plus the executed contract machinery above. It reports no measured live comparison (P01-E, P01-F pending) and establishes no Pi API contract beyond the cited source inspection of the candidate 1.6.0 artifact.