# Practice: predict, observe a failure, repair, then transfer

[中文](EXERCISES.zh.md) · [Assessment and observer protocol](ASSESSMENT.md) · [Blank submission](SUBMISSION_TEMPLATE.json)

Work from the extracted `harness-eval` directory. Keep package sources, fixed cases, graders and vendored runtime unchanged. Put your implementations and generated work outside it. The complete callable contracts are in [CASE_CONTRACT.md](CASE_CONTRACT.md) and [TRANSFER_CONTRACT.md](TRANSFER_CONTRACT.md); the measured comparison contract is in [EVAL_CONTRACT.md](EVAL_CONTRACT.md).

## Prepare once

Use Python 3.12 and a shell with a POSIX activation command:

```sh
python3.12 -m venv .venv
. .venv/bin/activate
python -m pip install -r runtime/requirements.txt
python -B -m unittest discover -s . -p 'test_*.py'
mkdir -p ../harness-eval-work
LAB_WORK="$(cd ../harness-eval-work && pwd)"
cp SUBMISSION_TEMPLATE.json "$LAB_WORK/submission.json"
```

The tests use explicit local model fixtures and custom SDK transports; they make zero paid requests. Transfer tests still launch actual local MCP processes and need permission to bind a local loopback socket. A blocked socket is an environment failure, not a passing exercise. Preserve the error and run in an environment that supports the local service.

Before any paid exercise, choose your existing private persistent budget ledger and configure credentials following the [runtime setup](runtime/README.md#setup-and-durable-limits). Set `PROVIDER_BUDGET` in your shell to that ledger's absolute path. Use that same path for all live exercises. Do not delete, copy to a fresh allowance, or reset it between exercises. The immutable guard limits the shared ledger to 20 attempts and USD2 in estimated standard token charges; failed and incomplete calls consume allowance. Credentials, tokens and private ledger contents do not belong in a submission.

## 1. Predict and repair the actual fault hook

Before opening `fault_reference.py`, fill the prediction section of your submission. For each situation, predict the action, expected transport-call count and why: recoverable read 429, read timeout, refusal, incomplete output, uncertain write, permission change, exhausted budget, and exhausted deadline. Explain how you would identify the original operation after an acknowledgment is lost.

Make your own external copy and run the real checker:

```sh
cp fault_student.py "$LAB_WORK/my_fault.py"
python -B fault_lab.py --student "$LAB_WORK/my_fault.py" --work "$LAB_WORK/fault-red"
```

A nonzero exit is expected: the all-stop starter passes 7 of 12 authored local scenarios. It loses recoverable work, does not reconcile an uncertain write, and does not express the required current-permission denial. The red result is an actual invocation of your imported hook. Missing or non-callable hooks also fail at that boundary. Inspect `fault-red/fault-report.json`; compare the action, original operation identity, bounded SDK transport calls and SQLite effects with your prediction. These are authored local injections through a real SDK parser, not observed provider outages.

Diagnose a specific failed scenario before editing. Repair only `my_fault.py`, then rerun the unchanged checker in a fresh fault work directory:

```sh
python -B fault_lab.py --student "$LAB_WORK/my_fault.py" --work "$LAB_WORK/fault-green"
```

Record both report paths and the submitted file's hash. Retrying a recoverable read must respect remaining time, call allowance and attempt limits. An uncertain write requires reconciliation using the same operation ID; never turn it into a fresh business operation. A changed permission is checked against current merchant authority. Merely stopping everything cannot complete the exercise.

The guided reference passes 12 of 12 under this same checker. After your diagnosis, you may inspect it or run it in a third fresh directory. Mark reference use honestly; copying it demonstrates reproduction, not independent transfer.

## 2. Read the paired evaluation without overclaiming

Read the two selected cases' model-visible context, write your expected decisions and evidence before looking at reference labels, and preserve that prediction. Then inspect the frozen comparison's raw responses and the freshly recomputed report. The 12 authored cases are public: six families with two variants each. `public_practice` and `public_transfer` are organizational names; both splits are readable and neither is an unseen test.

The paid comparison has two selected task clusters (`ordinary_complete`, `gift_exception`), two instruction versions and two independent repetitions per version: eight requests, four per version. Both versions receive identical context and output schema. Expected labels and semantic case IDs are excluded from model input. Repetition does not create eight independent task types. This measures the decision stage with supplied context, not tool retrieval, authorization, execution or whole-task success.

Verification makes no provider requests:

```sh
python -B evaluation.py verify --work /absolute/path/to/recorded-evaluation-work
```

A zero verifier exit means the evidence is internally verified; inspect the separate release gate. Record each version's completed/correct decisions, hard violations and actual hard false accepts separately. A hard false accept means `eligible` when the authored expected decision is not `eligible`; reference-label decision accuracy is a separate quantity. Structural citations and atomic claims do not certify the meaning of every prose sentence. Free-text review remains pending until a human actually performs it.

A strict atomic-support failure can coexist with a correct business decision. For example, policy rules may justify `eligible` while a cited record does not explicitly assert the extra `eligibility` claim. Classify the exact failed contract; do not automatically call it a business-decision error, hallucinated policy or unauthorized write. Keep the original grader after observing the result. Recorded observations and their scope are linked from the [package overview](README.md).

Copy exact known estimated costs, unresolved reservations, individual/mean latencies and their denominators from the verified evidence. Report ties or regressions as observed. With two public task clusters, do not claim general prompt improvement, a production success rate or p95 latency. A higher aggregate score cannot override a severe violation or insufficient task completion.

If you choose an additional paid reproduction, first inspect the same ledger's remaining allowance. This command consumes up to eight more attempts; it is not part of the free local tests:

```sh
python -B evaluation.py run --work "$LAB_WORK/evaluation-new" --budget "$PROVIDER_BUDGET" --repeats 2 --case-ids ordinary_complete gift_exception
```

Do not run it merely to obtain a better result, hide earlier failures or replace the shared ledger. Keep all attempts and original responses.

## 3. Break the old requirement, repair the same external hook

Before execution, predict what becomes invalid when the same order changes from an ordinary item under policy version 1 to a gift under version 2. Write down the evidence the new decision needs, whether the old approval can be reused, and what must happen if the current owner changes afterward. State which decisions belong to the merchant rather than the model.

Start from your own copy of the old-contract hook:

```sh
cp transfer_student.py "$LAB_WORK/my_transfer.py"
python -B transfer.py run --work "$LAB_WORK/transfer-attempt" --budget "$PROVIDER_BUDGET" --student "$LAB_WORK/my_transfer.py"
```

The starter is expected to return `blocked_student` before any candidate model call. The same work directory already contains an authored OfflineModel proposal obtained through actual MCP, the host's policy/order mutation and the actual merchant rejection of the stale approval. It must remain as the red evidence. This first run has no paid candidate calls, although it uses the persistent budget and local service.

Inspect `prior-task.json`, `policy-mutation.json`, `stale-approval.json`, the boundary records and raw MCP audit. Diagnose why reuse is invalid. Repair `my_transfer.py` at the same path, following the linked contract. Retrieve current gift context after the change; stop when current authority denies access. The hook selects requirements and gates continuation; it cannot grant merchant authority or bypass the stale-approval rejection.

Resume that same work after your repair:

```sh
python -B transfer.py resume --work "$LAB_WORK/transfer-attempt"
python -B transfer.py verify --work "$LAB_WORK/transfer-attempt"
```

Resume reloads the same external file and uses the saved budget path; do not pass a different student or budget. It is available only at the pre-model `blocked_student` boundary. Resume can make up to five actual model requests. A provider failure or a run that already reached the model is not eligible for this resume; record it and respect the remaining shared allowance.

A valid candidate retrieves the changed context through actual MCP and returns `manual_review` without a new proposal or business write. The host then changes the owner and proves a current-owner denial through actual MCP. The earlier authorized candidate is a historical observation, not continuing access for the old owner. Inspect the recomputed verification results and current effects, not only `report.json`.

## 4. Transfer requires a new observed task

Complete the evidence fields in your submission, preserving predictions, both external hook hashes, red/green paths, source fingerprints and the same-grader results. Leave human semantic review pending until a named reviewer actually reads the answer against evidence and authority. Use [ASSESSMENT.md](ASSESSMENT.md) for the rubric and a newly authored withheld variant.

A successful supplied reference proves this controlled demonstration. Your copied or independently repaired public exercises are practice evidence. A claim of learner transfer needs a recorded independent observer, a genuinely withheld new variant, a decision committed before execution, the unchanged locked checker and separate evidence/authority review. No actual learner results are supplied by this package.
