← Harness Engineering From First Principles

A Trace Is Not an Outcome

Compare baseline and instrumented runs; verify answers against repository fixtures and preserve raw events.

A Repo Scout evidence bundle reports VERIFIED_CORRECT for the task and COMPLETE for the trace. Its digests are consistent. Replay agrees. An independent reviewer then takes a real 45-event trace from that harness, deletes everything except four milestone events, re-signs the bundle and replays it. The result is again VERIFIED_CORRECT and COMPLETE (docs/research/HARNESS-PROJECT-01-REVIEW/README.md, finding P01R-02; OBSERVED). Three of the four surviving milestones had been written by the harness adapter itself. In that implementation, “complete” meant only that four events appeared in the expected order.

This chapter is about the gap that the experiment exposed. A trace is a record of what a system says happened. An outcome is a judgment about whether the world now matches what was required. Each depends on the other, and neither can stand in for the other. Project 01 is the book’s first checkpoint because, until this distinction is mechanically enforced, every later measurement in the book is only a measurement of what was logged.

In Chapter 1’s terms, this chapter is about the evaluation harness: the machinery that establishes what we can reasonably believe about what an agent did. The execution harness of Chapter 3 controls what the agent can do. The defects below show that the evaluation harness can fail on its own, while reporting success, even when execution has been tightly controlled. The original lab passed all 56 of its offline tests, which were written alongside the code by the same implementation stream. The failures were found only by an adversarial reviewer with no implementation role. Böckeler makes the general point for coding agents. She calls behavioural verification the hardest unsolved part of a harness, and judges current practice too reliant on AI-generated tests (Harness engineering for coding agent users, 2 April 2026; DOCUMENTED, practitioner assessment). Project 01 is a concrete instance of the problem: a passing self-authored suite, and an evaluation pipeline that was wrong in ways the suite could not see.

Evidence status. Draft manuscript. Project 01 checkpoint: not passed. The original offline review returned CONDITIONAL ACCEPT with blocking corrections. The first corrective freeze was re-reviewed and returned BLOCKED — FURTHER CORRECTION REQUIRED. The second freeze was independently re-reviewed and returned REJECT — candidate returned for correction (HARNESS-PROJECT-01-REVIEW-02, 2026-11-23): RER-01 and RER-03 corrected; RER-02 NOT CLOSED; RER-04/P01R-07 PARTIAL; P01R-02 NOT CLOSED (fresh zero-tool false success); P01R-27 blocking for IR-02. Live qualification (P01-E) and the comparative experiment (P01-F) have not been run. The verdict mapping of §4.4 is implemented and tested (D15-EVAL-01); the four-record separation, witness checks, replay integrity and the failure-mode table below are executed in the lab. Findings below are OBSERVED in the named review documents. The formal comparison remains EXPERIMENT PENDING.

4.1 Four records, four questions

A run produces material at several stages. Each stage answers a different question, and each stage can fail in its own way.

Record Question it answers Who produces it Typical failure
Raw observations What did the runtime, tools and supervisor emit, in what order? Pi event stream, tool handlers, supervisor Lost, duplicated or reordered events; a listener that throws
Normalized trace What does the harness assert happened, in its own vocabulary? Collector and normalizer Invented events, dropped events, a normalizer bug that loses detail
Lifecycle record Did the run reach a terminal state cleanly? Was cleanup confirmed? Supervisor Two terminal states, success marked before persistence, a hung child
Evaluation Is the required result true of the produced artifact? Independent evaluator with a sealed oracle Checking the wrong field, accepting unsupported citations

The book’s convention, inherited from the blueprint and repeated in every draft so far, is that these records are stored separately and versioned. The evaluator reads the earlier records and never rewrites them. The reason for the convention is easy to state. Every transformation between records is code, and code can be wrong. If the evaluator reads only the normalized trace, then any normalizer error becomes an outcome error that no later check can see. Keeping the raw record means a disputed trace can be re-derived. Keeping the evaluation separate means a disputed verdict can be re-run without touching the evidence.

4.2 Three graphs that should not be confused

Chapter 3 proposed (hypothesis H-ST, PROPOSED) that a harness directs intelligence through transitions between states. If that framing is used, three different graphs appear around a run. Much confused reasoning about agents comes from mixing them up.

Graph What it represents Where it lives in Project 01
State-transition graph What may happen next from the current state, and who may trigger it The run contract and the supervisor phases (Chapter 3, §3.4)
Execution / evidence graph What did happen, which step depended on which, and what supports what Raw events, normalized trace, tool-call/result links, citations to file ranges
Knowledge graph Which entities, facts, claims and relationships the system has represented The answer record’s assertions and the cited fixture facts

An outcome is none of these graphs. It is a judgment that relates the evidence graph and the produced artifact to an oracle that sits outside all three. A trace can be complete and the answer wrong. The answer can be right and the trace incomplete. A well-formed knowledge claim can cite evidence that does not support it. Treating any one graph as the outcome merges questions that need separate answers.

Two cautions keep this framing honest. First, “graph” here is a way of modelling the records, not a storage requirement. Project 01 needs no graph database, and nothing in this chapter argues for one. Second, it is an open question whether making these graphs explicit improves anything measurable. That question is registered as the representation study in Chapter 3 (§3.10) and remains EXPERIMENT PENDING.

4.3 Where “done” actually happens

A run reports “finished” at several boundaries, and they are not the same boundary. The Pi 1.6.0 audit establishes the runtime side (docs/research/HARNESS-RESEARCH-01/R02-PI.md; DOCUMENTED/OBSERVED source inspection for the artifact, TEST NOT RUN; not runtime qualification):

Boundary What the signal means What it does not mean
agent_end The low-level loop has completed a pass (C08) That no retry, compaction or queued work will follow
message_end A message has been emitted to public listeners That the message has been persisted. Persistence of a completed message follows public message_end (C09)
agent_settled The SDK considers the session settled; carries an aborted field (C08) Task success. aborted is cancellation evidence, not an outcome label, and it can precede deferred host actions
abort() / waitForIdle() Cancellation has been requested, and the runtime has gone idle (C11) Bounded physical termination, or rollback of anything already done
dispose() Listeners are disconnected after requesting aborts. Returns void (C11) That draining finished
Host finalization Drained, reconciled with canonical session state, one terminal record written Anything the host did not check (PROPOSED contract; candidate implementation not accepted)
Outcome The independent evaluator’s judgment against the sealed oracle Anything about the quality of the trace

A version note is needed because this point is easy to get wrong in print. agent_settled already exists in the Pi 1.0.4 artifact pinned by Book I. The aborted field is the documented later addition (R02, drift section). Calling settlement “a new 1.6 capability” would be incorrect.

The practical consequence for a host is an ordering rule. Subscribe before prompting. Treat public callbacks as synchronous and non-throwing; they should enqueue copies and do no I/O. Wait for settlement, then idle. Only then inspect canonical session state, reconcile it with the event record, and write the terminal record. A host that writes “completed” on agent_end has confused a statement about the reasoning loop with a statement about the world.

4.4 Outcome has several dimensions

The Project 01 candidate’s outcome record does not collapse into a single verdict. It carries separate dimensions (examples/pi-harness-lab/src/contracts.ts, working-tree candidate; Implemented-candidate, not accepted):

  • Task verdict: VERIFIED_CORRECT, VERIFIED_INCORRECT, INSUFFICIENT_EVIDENCE, INVALID_EVIDENCE_REF, ABSTAINED, EXECUTION_FAILED, EXECUTION_BLOCKED or EVALUATOR_ERROR.
  • Trace verdict: COMPLETE, INCOMPLETE or UNKNOWN. This is a judgment about the evidence, independent of whether the answer is right.
  • Run state and stop reason: whether and why the run ended. The host’s stop reason is recorded separately from the model’s own.
  • Cleanup: CONFIRMED or UNCONFIRMED.

Joint acceptance requires all of them. Crossing the first two dimensions shows why they must stay separate:

Trace COMPLETE Trace INCOMPLETE / UNKNOWN
Answer verified correct Acceptable, if lifecycle and cleanup also pass Right answer, unverifiable run. Report it; do not promote it
Answer verified incorrect A well-evidenced failure, and the most diagnosable result a harness can produce Failure with weak diagnosis. Keep both records

The top-right cell matters most. A system that merges dimensions will naturally “round up” a correct answer with a broken trace into a success. The book’s rule runs the other way: independent task truth is preserved, and execution acceptance is withheld. The first re-review saw the candidate do exactly this under a storage failure. The return channel reported RECORDING_FAILURE, a null evidence directory and failed execution, while keeping the independent VERIFIED_CORRECT task judgment (INDEPENDENT-REREVIEW.md; OBSERVED). The same probe also produced the duplicate terminal events described in Chapter 3 (RER-04). Getting the dimensions right does not by itself make the lifecycle right.

The book’s coarser reporting vocabulary, PASS / FAIL / REVIEW / UNKNOWN (Chapter 1), is best read as a projection of this record for summary tables. The mapping is implemented and tested in Chapter 15 §15.6 (D15-EVAL-01), which also records the book’s rule that an UNKNOWN from a broken trace is never promoted to PASS.

4.5 Worked example: T1 and four ways to fake it

Task T1 asks of the synthetic fixture repo-scout-v1: “Which file declares the function execute_with_retry?” The sealed oracle expects the fact worker, with an acceptable evidence locus of lines 12–16 of the file with ID worker (display path scheduler/worker.py) (oracle-data.ts, working-tree candidate).

The honest run. Event families as witnessed by the lab’s collector (witnesses.ts: startup, admission, model, tool, host, final families; exact names in the transcript expectations). The scripted provider stands in for the model; every other row is executed machinery:

ADMITTED   admission.accepted   fixture=<sha256>  oracle sealed
STARTING   startup.config       effective settings asserted
RUNNING    model.request #1     → proposes fixture_list {}
           tool.start/result    catalogue: 6 files, full 64-char digests
           model.request #2     → proposes fixture_read {fileId:"worker", startLine:12, endLine:16}
           tool.start/result    numbered lines 12–16, file digest, fixture digest
           model.request #3     → final assistant message containing the answer record
FINALIZING agent_settled (aborted=false) → waitForIdle → canonical messages reconciled → queue drained
EVALUATE   oracle(answer, fixture, run identity)
TERMINAL   one supervisor.terminal record

The answer record follows the offline contract’s shape (§3), with the frozen digests filled in from the admitted fixture:

{
  "schemaVersion": "answer-v1",
  "runId": "<run>", "fixtureSha256": "c1a23100463dcaa9aa2f68ee0778d182139bf28624d6cd0ad6b21c2ed02457ad", "questionId": "T1-declares-retry",
  "answer": "worker",
  "assertions": ["execute_with_retry is declared in worker"],
  "citations": [{ "fileId": "worker", "contentSha256": "77062c24a001f6a054ded36b9f387d4264ec31f62b3c6e0107bd81eef5b85b87",
                  "startLine": 12, "endLine": 16 }]
}

The evaluator works in order. It validates the schema. It binds the answer to this run, attempt, fixture and question. It checks the answer value and every assertion against the expected fact. It checks that each citation names an admitted file, carries that file’s full digest and lies inside an acceptable locus. It rejects any extra unsupported assertion. Only then does it return VERIFIED_CORRECT.

Four ways to fake it. Each row below is a real defect from the Project 01 reviews. In each, the harness held a record that looked like evidence, and a check that read the record when it should have checked the world or an independent observation.

Attack What the record showed Original or first-freeze behaviour (OBSERVED) Required behaviour Current status
Inconsistent answer. answer: "scheduler" with assertion “worker” A correct-looking assertion and citation Accepted as VERIFIED_CORRECT. The evaluator never compared the top-level answer (P01R-03) VERIFIED_INCORRECT First re-review observed the wrong displayed answer now judged VERIFIED_INCORRECT
Milestone trace. 45 events reduced to 4 and re-signed An ordered subsequence of required milestones COMPLETE, replayed as verified. The witness accepted any ordered subsequence, three of them adapter-written (P01R-02) INCOMPLETE. Model request/response, tool and settlement families are all required First re-review observed reduction to four milestones failing replay acceptance
Failed parent, healthy record. Parent exit code 1, SIGTERM, or bundleWritten: false, with digests repaired A consistent bundle with valid receipt digests Replay returned VERIFIED_CORRECT / COMPLETE / completed (RER-01). The live supervisor rejected these; replay did not apply the same rule Replay rejects contradictory terminal claims Original four RER-01 mutations reject (REVIEW-02: CORRECTED); failed-receipt on-disk bundle remains readable-success (PARTIAL, blocking persistence work; replay fails closed).
Self-reported accounting. Worker summary claims 0.5 model calls, or zero tool bytes A plausible usage summary Accepted with no anomaly; actual trace showed 3,227 bytes (RER-02) Reconcile the summary with events; integer counters Live-side summary checks corrected; replay-side reconciliation NOT CLOSED (fake aggregate-usage and evaluation-detail forgeries replay as matching; REVIEW-02 RER-02).

There is a fifth defect, and it points the other way. In the original lab, tool output exposed only the first 12 of the 64 hash characters that a valid citation required. The passing tests injected the full hash out of band (P01R-01; OBSERVED, Critical). The trace and the evaluator were both consistent, and yet no model could have produced a passing citation from what it was shown. The evidence pipeline was sound, but the task as presented could not be completed. The first re-review observed full digests present in both tool responses after correction. Chapter 5 begins from this defect. Question premises can themselves fail: T4’s wording conflicts with the fixture code (see Ch 5 §5.6); an oracle can produce false failures, not only false passes.

4.6 You cannot verify a trace with itself

Every attack in §4.5 succeeded for the same structural reason. The check that accepted the record depended on the component that produced it. An adapter wrote the milestones that the witness required. The worker wrote the summary that the host summed. The bundle carried the digests that replay compared. The design response that follows has three parts.

Independent witnesses. For offline qualification, the expected transcripts are authored separately from collector output. They are fed through the scripted provider and tools, and then compared with what the collector recorded. A witness must not depend on the collector path it is checking (OFFLINE-IMPLEMENTATION-CONTRACT.md §5; PROPOSED). Corrupting only the derived normalized records is not a sufficient test. Loss has to be injected before sequence assignment, during the queue write, during normalization and at the tail before finalization.

Counted detection. A collector check is a sensor, and sensors have two error rates. For each fault class (omission, duplication, reordering, truncation, sink failure) the qualification records the expected count, the detections and the false alarms on clean transcripts. This is needed because a silent sensor is ambiguous. Böckeler makes the same point about coding-agent harnesses: a sensor that never fires may mean high quality or weak detection, and there is currently no good way to tell which (Harness engineering for coding agent users, martinfowler.com, 2 April 2026; DOCUMENTED, practitioner assessment, not an experimental result). Fault injection with known counts is how this book gives a silent sensor a meaning. The opposite error is real too. In a follow-up that tried concrete maintainability sensors, the same author found new rule sets surfacing a mix of irrelevant and meaningful issues, and warned that feedback overload could push an agent into over-engineered refactorings (Maintainability sensors for coding agents, 27 May 2026; DOCUMENTED). A collector that raises false alarms on clean transcripts fails H2 below as surely as one that misses a fault.

Honest limits on integrity. Hashes detect drift. They do not establish authenticity. An actor who can rewrite a bundle and recompute every ordinary hash can forge a self-consistent record. The candidate’s replay therefore reports provenance as UNKNOWN rather than claiming trusted capture (REMAINING-RISKS.md §4; confirmed limitation). Loss that happens upstream of every observation point, without an independent witness, also stays UNKNOWN. Sequence numbers cannot detect an event that never reached the collector. This book will not claim universal capture completeness.

4.7 Project 01 checkpoint

Repo Scout: answer verifiable questions about a codebase. The new harness mechanisms are an admission contract, a Pi SDK adapter, structured traces and a fixed baseline. The required verification is that every answer has source evidence, that there are no effects, and that model/config digests and token use are recorded (blueprint, project table).

Where it stands (as of the documents cited; nothing below is an acceptance):

Gate element Status Source
Research for offline foundation CONDITIONAL GO (IR-01–IR-04 at specification level) HARNESS-RESEARCH-01/GATE-DECISION.md
Offline implementation Original: CONDITIONAL ACCEPT, blocking corrections. First freeze: BLOCKED (RER-01–RER-04). Second freeze: independently re-reviewed, REJECT (RER-01, RER-03 corrected; RER-02 NOT CLOSED; RER-04 PARTIAL; P01R-02 NOT CLOSED; P01R-27 blocking IR-02); 106/106 reproduced independently, still implementer evidence, not acceptance. P01-E/P01-F/Gate C pending. HARNESS-PROJECT-01-REVIEW/, HARNESS-PROJECT-01-FIX-01/
Implementer regression 106/106 offline tests reported on the second freeze. Implementer evidence, not acceptance HARNESS-PROJECT-01-FIX-01/TEST-RESULTS.md
Independent evaluation (P01-D) PASS within frozen-task scope at first-freeze re-review; no general entailment claim INDEPENDENT-REREVIEW.md
Live qualification (P01-E) NOT RUN. No provider credential, authorized spend or metering REMAINING-RISKS.md §2
Comparative experiment (P01-F) NOT RUN. EXPERIMENT PENDING —
Security qualification (Gate C) PENDING. The two-tool allowlist is an application-level restriction, not an OS sandbox REMAINING-RISKS.md §3

Predictions to register before P01-F (PROPOSED; to be frozen in the registration manifest before any treatment result is viewed):

  • H1. Interface equivalence. Adding raw-event capture (arm B) leaves the model-visible request bytes identical to arm A at every turn, including tool-result turns. Testable offline. Falsified by any byte difference at the model-request boundary.
  • H2. Detection. On arm C, the collector reports INCOMPLETE for every injected fault class at every injection point in §4.6, and reports zero false alarms on clean independent transcripts. Testable offline. Falsified by any missed injected fault or any false alarm.
  • H3. Overhead. Arm B’s task outcomes, resource use and latency fall within the registered overhead tolerance relative to arm A. Requires live runs. The tolerance has not yet been chosen, and a small pilot cannot prove equivalence. Logger-caused failures count against arm B; they are not excluded.

Passing H1 and H2 would establish the tested collector behaviours and interface equivalence at the inspected boundary. It would not show that the model’s stochastic outputs are identical, that the harness is secure, or that any agent became more capable.

4.8 Failure modes

  • Loop end read as success. Writing “completed” on agent_end. Defence: settlement, idle, reconciliation and the evaluator, in that order.
  • Self-witnessing. The component that produces evidence also defines what complete evidence looks like. Defence: independently authored witnesses and fault injection below the collector.
  • Rounding up. A correct answer with a broken trace reported as a success. Defence: separate verdict dimensions and joint acceptance.
  • Field blindness. The evaluator checks citations but not the answer value, or the other way round. Defence: every field in the answer record is either checked or rejected as unexpected.
  • Replay leniency. Live execution enforces a rule that replay does not. Defence: one acceptance function, used by both.
  • Impossible task. The pipeline is sound, but the interface withholds information the oracle requires (P01R-01). Defence: derive the oracle’s requirements from what is actually model-visible, and test the positive path without out-of-band help.

4.9 What you can build and test now

All five now exist in the lab, cited to their evidence:

  • Four separate records with separate schema versions, plus a test that re-derives the trace from raw events (recorder + replay suites).
  • The evaluator rejecting answer: "scheduler" with assertion “worker” for T1, and valid answers with out-of-locus citations (evaluator suite; D15 mapping tests).
  • Independently authored expected transcripts with every fault class injected at each point in §4.6, publishing detections and false alarms including the failing cells (witness + collector-fault suites assert zero false alarms on clean transcripts; P01R-27 closure itself awaits independent re-review).
  • A replay suite altering lifecycle facts and recomputing every ordinary digest, requiring rejection (replay + closure suites; RER-01 shape).
  • Finalization ordered settlement → idle → canonical reconciliation → drain → evaluate → single terminal record, asserted in a test (supervisor lifecycle; RER-04 shape).

4.10 What remains unverified

  • Re-review of the second freeze is complete (REVIEW-02, REJECT). RER-02, RER-04, P01R-02 and P01R-27 remain open; RER-01 and RER-03 are corrected for the tested attacks.
  • Live behaviour of any model under the tool and answer contract: whether it uses full-hash citation metadata, follows the assertion contract, abstains appropriately, or is affected by prompt injection or semantic ambiguity (REMAINING-RISKS.md §2).
  • Exact pinned Pi event names and multiplicity for every required event family. The contract requires an identity/multiplicity map; this chapter uses family-level names.
  • Cross-platform behaviour. All review evidence is Windows x64 on a single Node version.
  • Human acceptance of the T1–T6 fixture and oracle, and the mapping from the candidate’s verdict set to the book’s PASS / FAIL / REVIEW / UNKNOWN reporting vocabulary. The mapping decision now lives in Chapter 15 §15.6 and is implemented and tested (D15-EVAL-01); glossary adoption and human acceptance remain open.

EXPERIMENT PENDING. Project 01’s comparative study has not run, and its offline foundation is not accepted. This chapter reports review findings within their stated scope, registers predictions, and points to the executed record/evaluation machinery above; it reports no measured live comparison.

Previous: Chapter 3: The Run Contract and Baseline.

Next: Chapter 5: Tool Schemas as Cognitive Interfaces.