# Harness evaluation and changed requirements

[中文](README.zh.md) · [Exercises](EXERCISES.md) · [Observed evidence](https://ai.lwkjob.com/research-evidence/harness-eval/README.md)

Continue the [same return-service project](https://ai.lwkjob.com/notes/harness-end-to-end-project/). This package adds a fixed decision dataset, fault decisions and a changed-requirement capstone. The merchant, policies, identities and mutations are fictional local fixtures. The OpenAI model and official MCP subprocesses are real when the explicitly paid commands run.

The immutable `runtime/` is a byte-for-byte copy of the previous published live package, with 58 file hashes in `RUNTIME_PROVENANCE.json`. Edit your own submission files outside this directory. Do not change the reference cases, grader or frozen runtime to make a result pass.

## Setup

Use Python 3.12 and an isolated environment:

```sh
python3 -m venv .venv
.venv/bin/python -m pip install -r runtime/requirements.txt
.venv/bin/python -B -m unittest discover -v
mkdir submissions
cp fault_student.py submissions/fault.py
cp transfer_student.py submissions/change.py
```

Tests use authored models or a custom SDK transport and make zero paid requests. The transfer test starts an actual local HTTP merchant and actual MCP subprocesses; it needs localhost sockets. These fixtures are not model quality or provider reliability observations.

## Three boundaries to inspect

1. **Decision evaluation:** 12 public authored cases, six families × two variants. Both `public_practice` and `public_transfer` are readable. The recorded paid comparison selects two cases × two prompts × two independent repeats = eight Responses POSTs. Both versions see the same context and JSON schema; only instructions differ. Expected labels and semantic case IDs stay outside the model input. This evaluates a decision from supplied context; it does not run retrieval, tools, approval or merchant execution.
2. **Fault decisions:** execute the actual `decide_next` hook against 12 local injected scenarios. The safe all-stop starter passes 7/12; it fails required recovery/completion. The supplied reference passes 12/12 with the unchanged checker. HTTP 429, timeout, refusal and incomplete responses are authored SDK transport injections. SQLite demonstrates a commit followed by lost acknowledgment and reconciliation of the original operation ID.
3. **Requirement changes:** an authored OfflineModel creates the prior ordinary-item proposal through actual MCP. The fixture changes the same order to gift and policy version 2. The actual merchant rejects the stale approval. Your hook must request current evidence before any paid candidate runs. Repair the same file and resume the same work. A new real model candidate must read the gift policy and return manual review without a proposal or business write. A later owner change must deny the old actor at the merchant boundary.

Exact interfaces live in [CASE_CONTRACT.md](CASE_CONTRACT.md), [EVAL_CONTRACT.md](EVAL_CONTRACT.md) and [TRANSFER_CONTRACT.md](TRANSFER_CONTRACT.md). The transfer hook cannot grant authority; current merchant reads and stale approval rejection execute independently of learner code.

## Run the zero-paid-call fault exercise first

```sh
.venv/bin/python -B fault_lab.py --student submissions/fault.py --work work/fault-red
# Predict, inspect fault-report.json, then repair submissions/fault.py.
.venv/bin/python -B fault_lab.py --student submissions/fault.py --work work/fault-green
```

The first command deliberately exits nonzero. Preserve both work directories and your patch. Do not replace the starter with the reference and call that independent mastery. Follow [EXERCISES.md](EXERCISES.md) and the bilingual [observer protocol](ASSESSMENT.md).

## Paid commands and durable limits

Supply your own `OPENAI_API_KEY` through your process environment; never put a secret in source, shell command arguments or evidence. Use one explicit private persistent budget path across all live runs. The unchanged transport atomically reserves before each POST and caps the whole ledger at 20 attempts / USD 2 estimated standard-price cost. Failures consume attempts; missing usage keeps its conservative reservation. SDK retries and redirects are disabled. Do not delete, replace or reset a ledger to continue an exhausted allowance. The recorded project reused its earlier ledger, including the prior seven requests.

These commands spend money and require a configured key and enough allowance:

```sh
.venv/bin/python -B evaluation.py run --work work/paired --budget private/provider-budget.sqlite --repeats 2 --case-ids ordinary_complete gift_exception
.venv/bin/python -B transfer.py run --work work/change --budget private/provider-budget.sqlite --student submissions/change.py
# The supplied change starter blocks before the paid candidate.
# Repair the same submissions/change.py; retain the same work and ledger.
.venv/bin/python -B transfer.py resume --work work/change
```

The comparison plans eight POSTs. The transfer candidate permits at most five Responses turns; the budget may stop it sooner. Resume only supports the pre-model learner block, not retrying paid provider failures. The prior proposal is an explicit authored fixture, not an earlier paid model result. The reference implementation is a guided demonstration, not a production gateway.

## Verify and interpret

```sh
.venv/bin/python -B evaluation.py verify --work work/paired
.venv/bin/python -B transfer.py verify --work work/change
.venv/bin/python -B package.py --out harness-eval-v1.zip
```

Verification makes no provider calls and recomputes gates from recorded requests, raw responses, ledger snapshots, source hashes, task stores and MCP events rather than trusting a saved green report. The evaluator can use the saved public ledger snapshot; if the original private ledger exists it also cross-checks its rows. The transfer verifier requires the closed, checkpointed SQLite work files. Those private work databases are excluded from this source ZIP and public evidence; the public JSON exports allow inspection, not a claim that a reader reran that private database verification.

Decision, trusted citation and structured atomic claim checks are independent dimensions. A real citation does not support an arbitrary claim. Full natural-language semantic review remains `pending_human`. `integrity_pass` means the evidence is internally consistent; inspect the separate release gate and per-version results. Any severe violation or required incomplete task blocks the corresponding automatic gate even if an aggregate score improves. An automatic gate is necessary, not final human release approval.

Keep denominators: two authored task clusters, two repeats, four attempts per version, eight attempts total. Ties and regressions are valid results. This sample supports neither a general prompt improvement claim nor production p95, SLA or a reliability rate. Request latency excludes tools; the inclusive transfer window includes local MCP startup and operator repair time. Do not add overlapping stages. Cost is an estimate from returned usage at the pinned model's [published standard prices](https://developers.openai.com/api/docs/models/gpt-5.4-mini), not an invoice.

Use [SUBMISSION_TEMPLATE.json](SUBMISSION_TEMPLATE.json) to record predictions, original failures, your patch, unchanged-checker results and independent review. No human learner has been measured in the supplied demonstration. A newly authored observer-held variant and a learner's independent implementation are still required to assess transfer.
