← Harness Engineering From First Principles

What Is a Harness and What Is Not?

Map a task through the proposed layers and identify which component owns each decision.

This chapter defines the book’s working vocabulary: the model, the agent runtime, the harness host, the application, the effect broker, the evaluator, and the adaptive policy component. Each definition is a PROPOSED book-local convention, not a claim about any vendor’s architecture. An offline Project 01 implementation exists as an unaccepted candidate; no comparison has been measured.

Evidence status. This is a draft manuscript, not a result report. The six research tracks (R01–R06) and a separate review are complete. They returned a CONDITIONAL GO for the offline Project 01 foundation only (docs/research/HARNESS-RESEARCH-01/GATE-DECISION.md). That is not full-book Gate A acceptance, and the Project 01 implementation has not been accepted (Chapter 4). Every substantive external claim in this chapter is labelled with the book’s evidence categories — Established, Implemented, Experimentally demonstrated — and its provenance — DOCUMENTED, OBSERVED, PROPOSED, UNKNOWN. Where a check has not been run, the chapter says EXPERIMENT PENDING for the formal comparison it belongs to. Raw observations, normalized traces, and evaluator judgments are kept separate throughout the book; a trace is never treated as an outcome (Chapter 4). The end-to-end walkthrough D01-WALKTHROUGH is implemented and executed (examples/pi-harness-lab/test/harness-walkthrough.test.ts, 3/3 pass offline): one task through context selection, routing, authority, spend reservation, the durable journal, evaluation and verdict mapping, plus the negative paths and §5.7 interface-cost accounting through the real tool handler. No live model run, comparative study or security boundary is claimed.

1.1 Five things people mean by “agent”

The word agent is overloaded. It is used for a model, for a loop that calls tools, for a shipped product, and for a research result. This book separates those meanings because each one assigns responsibility for a different decision. The separation below is PROPOSED; it follows the layer model in planning/source/harnesses-book-blueprint.md, which is an authoring input, not a verified source.

Component Owns Does not own
Model / provider Next-token predictions given a context window Tool execution, permissions, persistence, completion
Agent runtime (Pi) The model/tool loop, session state, event stream, extension and tool invocation Policy enforcement, durable task state, independent evaluation
Harness host Run contracts, admitted capabilities, budgets, plans, application state, coordination, settlement Model reasoning, OS-level isolation by itself
Effect broker + sandbox Real authorization and isolated execution of durable effects Deciding what the agent should attempt
Evaluator + evidence ledger Independent pass/fail checks, artifact verification, preserved traces and cost records Helping the agent finish the task
Adaptive policy component (ECK-style) Proposing strategy changes against evidence, subject to governance Direct execution, approval, or self-promotion

Two further distinctions matter. An application (for example, a CLI or an optional Mission Control surface) initiates runs and displays evidence; it should not become a second agent loop. An ECK-style component selects policies above the loop — which strategy to try next — rather than reasoning inside the loop. The existing ECK lives in the Writer ecosystem and is not this book’s component: initial intake points at C:/Projects/praxis (commit 9cbc59038d38bc37d1093c4f236497fdb3f22715), its praxis/eck_adapter.py, and Writer-side strategy/lesson records. Research track R06 found that Writer runtime/domain code and a narrower Praxis adapter both exist (OBSERVED source; unqualified inspection). It also found that the inspected retrieval, selection and promotion paths do not by themselves establish temporal eligibility, held-out improvement or human activation approval (HARNESS-RESEARCH-01/CLAIM-LEDGER.md H01-C14/C15). Repo Scout therefore takes no ECK dependency (H01-P03, PROPOSED). This book treats ECK as a named open question from Chapter 25 onward, not as a selected architecture.

Microsoft’s Agent Framework harness and Agensh appear in this book only as PROPOSED comparative references, not as a selected implementation. The blueprint proposes porting interfaces and invariants rather than source or a second runtime, in TypeScript around Pi. Research track R01 found that Agensh’s pinned Pi adapter delegates to native Pi RPC and relies on outer supervision (CLAIM-LEDGER.md H01-C07; OBSERVED source, no adapter execution). The Agent Framework source, version and license audit remains incomplete (H01-C08, UNKNOWN). The book therefore reuses invariants, not another runtime, and makes no normative claim about Agent Framework source.

1.2 One task, walked through the layers

Consider a deliberately small, read-only task of the kind Project 01 (Repo Scout) freezes into a fixture. The fixture is a tiny synthetic repository (repo-scout-v1), and one of its questions is:

“Which file declares the function execute_with_retry?” Answer with a structured record whose citations name a file ID, its content digest and a line range.

Here is who decides what:

  1. Application admits the task: it registers the fixture digest, the question text, the allowed tools, the model configuration digest, and the budget (tool calls, bytes, wall clock). No reasoning has happened yet; this is administration.
  2. Harness host opens a run under that contract, attaches a sealed acceptance oracle (an independent check of the fact and of the cited lines), and starts the runtime with only two data tools, fixture_list and fixture_read. These serve immutable, preloaded fixture text by opaque file ID. The model never resolves an operating-system path.
  3. Agent runtime (Pi) reasons, proposes calls to those tools, and streams events. It may be wrong; being wrong inside the loop is normal and recoverable.
  4. Effect broker: none in Project 01. The task has no effects, and the two-tool restriction is enforced by the host’s tool handlers inside the worker process. That is an application-level capability restriction, not an OS sandbox. The process keeps the user’s OS authority, and security qualification (Gate C) is pending. A broker with real isolation is proposed for Project 05 (Chapters 11–12); the first write-precondition gate is staged publication in Chapter 6, without isolation.
  5. Evidence ledger preserves separate records: the raw runtime events, the normalized harness trace (what was attempted and observed), the lifecycle record, and the answer artifact with its hash.
  6. Evaluator runs the oracle against the answer after the run and records a task verdict separately from a trace verdict, without editing either input (Chapter 4, §4.4). A fluent, confident answer with an unsupported citation fails.
  7. Adaptive policy (later chapters) may eventually propose: “prefer structural search before full-file reads for this task family.” That proposal enters a registered prediction, is tested on held-out tasks, and is promoted or reverted by evidence plus a human decision — never by its own advocacy.

The point of the walkthrough is ownership. If the answer cites a file that does not exist, the defect belongs to the run’s evidence chain (what did the oracle check?), not to “the model” in the abstract. If the run reads outside the fixture, the defect belongs to admission and the tool boundary, not to the prompt. Each failure has an address. The walkthrough above is executed as D01-WALKTHROUGH: the same seven steps run as composed deterministic mechanisms, and the negative paths — a refused route, an unsupported claim — end in REFUSED, UNKNOWN and INCOMPLETE rather than in silent success.

1.3 What the harness owns — and what it must not claim

The harness host owns the decisions that make a run an experiment rather than an anecdote: the registered contract, the frozen fixture, the admitted capabilities, the budget, the settlement check (did the work actually complete, including effects the loop can no longer see?), and the preserved evidence bundle. Chapter 3 turns this list into a run contract; Chapter 18 turns it into reproducibility rules.

Equally important is what the harness does not own:

  • It does not reason. Replacing Pi’s loop with a second planner inside the host duplicates the runtime and creates two places where “done” is decided. The blueprint’s hard constraint stands: never fork or replace the runtime to implement a feature that belongs at a host or tool seam.
  • It does not authorize by persuasion. A prompt, a skill description, or an agent’s assurance never grants authority. Authority lives in the broker and the sandbox, outside the model and outside same-process extensions. R04 found that Windows lexical path checks and read-only tool schemas do not by themselves establish object containment or race-free access (CLAIM-LEDGER.md H01-C11; DOCUMENTED OS semantics; design inference PROPOSED). No native broker has been qualified, and security Gate C is pending. Full argument: Chapters 11–12.
  • It does not evaluate its own work. The code that helps the agent finish cannot also judge whether it finished. Outcome oracles, process checks, and human review are structurally separate (Chapters 15–16).
  • It does not learn by assertion. Experience selection, strategy proposals, and promotion rules are governed mechanisms with leakage controls and rollback — or they are absent. Chapters 21–26 keep them absent until the evidence earns them.

Two distinctions organize the rest of the book. The first is between the execution harness and the evaluation harness. The execution harness controls what an agent can do: admission, tool surface, budgets, state transitions, effect authority. The evaluation harness establishes what we can reasonably believe about what it did: preserved evidence, independent oracles, replay, and the honest reporting of unknowns. The two overlap, since the same event stream feeds both, but neither implies the other. A tightly controlled run can still be judged by a defective evaluator, and Project 01’s reviews found exactly that (Chapter 4). A rigorous evaluator does not make an uncontrolled run safe. Neither, on its own, guarantees security or correctness. This is a PROPOSED book convention. It sits close to Böckeler’s practitioner framing of harness controls as feedforward guides, which steer an agent before it acts, and feedback sensors, which observe what it did so it can self-correct (Harness engineering for coding agent users, martinfowler.com, 2 April 2026; DOCUMENTED). Her framing classifies controls. This book’s distinction asks instead which claim a mechanism supports: what could happen, or what we know happened.

The second is the book’s central architectural hypothesis, H-ST (PROPOSED): 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 and authorized, and how each is verified, recorded and retained. Chapter 3 (§3.4) applies H-ST to a single run, Chapter 4 (§4.2) separates the state-transition, evidence and knowledge graphs that the hypothesis implies, and Chapters 6 (§6.6), 9 (§9.5) and 10 apply it to edits, recovery and effects. Whether explicit graph representations beat a plain state machine is registered as an experiment, not assumed (Chapter 3, §3.10).

1.4 Benefits and failure modes

Each harness mechanism in this book must earn its place against the same question: with model, task, environment, and budget held constant, what does it improve? The default answer may be nothing, and a measured negative result is a valid result. Two tables set expectations honestly.

What a harness can add (each now demonstrated at least in its deterministic core; formal comparisons remain pending):

  • Attribution. When every effect carries an authorization reference and every artifact carries a hash, failures become diagnosable — executed in the walkthrough’s journaled trail and the merge/delegation records (D19, D20).
  • Containment. A broker with real isolation converts “the agent should not” into “the agent could not.” Not demonstrated: no qualified isolation exists (Chapter 12 stays pending).
  • Continuity. Durable state converts a crash from a mystery into a recovery test with a known fault point — executed across real process restarts (D09, D10).
  • Comparability. Frozen fixtures, digests, and budgets convert demos into paired baseline/treatment/ablation trials — executed for the offline machinery (presence tests, gate checks, replay); the live comparisons are pending.

How harnesses typically fail (antipatterns this book tests for):

  • The second loop. Host planning logic re-implements loop control; the runtime and host disagree about state. Symptom: UNKNOWN outcomes the ledger cannot settle.
  • Prompt-as-policy. “Only read files under X” written in a system prompt and called a boundary. Symptom: passes demos, fails path-escape tests.
  • Trace-equals-outcome. Treating loop termination (agent_end-shaped signals) as task settlement. Symptom: effects unverified, success claimed before the oracle runs. The R02 audit of Pi 1.6.0 documents that agent_end is a low-level completion that retry, compaction or queued work may follow, and that agent_settled is a separate signal which still does not mean task success (R02-PI.md C08; source-inspected for that artifact, DOCUMENTED/OBSERVED, TEST NOT RUN; no runtime qualification). See Chapter 4, §4.3.
  • Budget illusion. A treatment “wins” by spending more tokens, time, or parallel agents. Symptom: disappears under matched-total-budget comparison (mandatory from Project 08 onward).
  • Leakage. Future or held-out information reaches the run through retrieved history or a tuned prompt. Symptom: gains that do not transfer to frozen unseen tasks.

1.5 How to read the evidence in this book

Every empirical statement in later chapters carries two labels. The evidence category says what backs it: Established (primary documentation or prior research, cited with revision), Implemented (inspected code plus passing tests, with commands and checkout recorded), or Experimentally demonstrated (reproducible measurements from this book’s projects, with model, fixture, budget, seeds, and independent outcome). The provenance says where the claim stands: DOCUMENTED, OBSERVED, PROPOSED, or UNKNOWN. Published results — Stencil’s edit-format study, Harness-Bench trajectories, agentic-harness-engineering reports — can establish what their authors report; they are never this book’s experimental demonstration. Gate A exists to force this discipline before implementation begins.

Outcome labels follow the same separation. The summary vocabulary PASS / FAIL / REVIEW / UNKNOWN used in tables is a projection of a richer record. That record holds a task verdict, a trace verdict, a run state with its stop reason, and cleanup status, each judged separately (Chapter 4, §4.4). A proposed mapping is given in Chapter 15 §15.6.

Separation of concerns, not a Pi API claim. The shape below is adapted from the blueprint’s proposal to show the intended separation of concerns. The division it shows is executed as D01-WALKTHROUGH (each record below has a producing mechanism named in Chapters 2–4); no Pi SDK function is invoked or asserted here.

// Executed division of concerns (D01-WALKTHROUGH); not a Pi API.
type Verdict = "PASS" | "FAIL" | "REVIEW" | "UNKNOWN";

interface IllustrativeRun {
  runId: string;            // host-assigned
  taskDigest: string;       // frozen fixture + objective + oracle version
  modelConfigDigest: string;
  harnessConfigDigest: string;
  allowedCapabilities: string[];  // admission; enforced at the tool boundary
                                  // now, by a broker from Project 05
  state: "ADMITTED" | "RUNNING" | "AWAITING_APPROVAL"
       | "EVALUATING" | "COMPLETED" | "FAILED" | "CANCELLED" | "UNKNOWN";
  // Historical blueprint vocabulary, superseded as a state contract.
  // Chapter 3 §3.4 is the operative phase table; do not implement this enum.
  // Candidate `RunState`/supervisor phases differ from this sketch; the operative table is §3.4.
}

// Raw runtime events, normalized harness facts, and evaluator judgments
// are stored in three separate records. The evaluator reads the first
// two; it never rewrites them.

1.6 What remains unverified

The research dossiers (R01–R06) and their review are complete; see docs/research/HARNESS-RESEARCH-01/. What they leave open:

  • R01: The Agent Framework source, version and license audit is incomplete, so it supports no normative claim or code reuse.
  • R02: The inspected Pi 1.6.0 artifact is the candidate pin. Its seams are source-inspected, not tested by this book. Book I’s 1.0.4 pin does not select this book’s dependency.
  • R03: Published harness comparisons do not isolate single mechanisms. Harness-Bench’s retrieved abstract and full text disagree on task totals, so no count from it is accepted here.
  • R04: No isolation or broker deployment is qualified. Gate C is pending. Checkpoint, recovery, journal and broker-decision mechanisms are executed as educational demonstrations (D09, D10, D12-BROKER-01); confinement is not.
  • R05: Variance, grouping and matched-budget rules are specified, but no local measurement exists.
  • R06: The existing ECK code is real, but its benefit and governance path are untested. Nothing is needed from it before Project 10.

Every mechanism in this book remains a hypothesis with an experiment design until an executed result says otherwise; the executed demonstrations are named where they exist.

EXPERIMENT PENDING. No comparative run has been executed. No Pi API contract is established here beyond the cited source inspection. Project 01’s offline implementation is an unaccepted candidate, and its comparative study has not run (Chapter 4).

Next: Chapter 2: From Pi Agents to a Controlled Host.