# Repair a proof, keep the failure

[中文](WALKTHROUGH.zh.md) · [Setup](README.md) · [Exact contract](CONTRACT.md)

Work through these steps with the v2 checker and fixtures unchanged. The reference is author-assisted teaching material. Reproducing it is guided practice; an independent learner assessment would require a new observer-held variant and the learner's own work. No such learner results are reported here.

## 1. Before: inspect the actual failed response

Open [the complete original request and response JSONL](examples/v1-recorded-trace.jsonl). The request and response both carry `attempt_id: 8`. In the response, `raw_response.output[0].content[0].text` is the **full original answer JSON**, encoded as a JSON string. Decode it without editing the trace:

```sh
../harness-contract-venv/bin/python -B - <<'PY'
import json
from pathlib import Path
rows = [json.loads(line) for line in Path('examples/v1-recorded-trace.jsonl').read_text().splitlines()]
response = next(row for row in rows if row['event'] == 'provider_response')
print(json.dumps(json.loads(response['raw_response']['output'][0]['content'][0]['text']), indent=2))
PY
```

Its decision is `eligible`. Its seven direct facts have supporting records. It also contains this claim:

```json
{"field":"eligibility","value":"eligible","evidence_ids":["access-check","order-record","proof-check","policy-current"]}
```

Those are real trusted record IDs, but none directly asserts that field/value. The unchanged v1 checker requires direct support for each claimed field/value in **every** cited record. Decision and citation checks can pass while the atomic-claim check fails. The recorded answer remains a hard failure; deleting its eligibility claim would create a new edited answer, not repair the historical observation. The original v1 comparison remains **0/4 and 1/4**.

## 2. Diagnose the contract ambiguity

The old schema allowed eligibility in the same list as direct facts, while its checking rule accepted only direct assertions. The business policy required a derivation, but there was no typed proof format for that derivation. More citations cannot supply the missing proof. Nor should the checker pretend a receipt audit directly asserts a policy conclusion.

The repair changes the contract: keep directly stated facts as atoms; represent eligibility separately as a registered rule application. Scope is explicit: tenant, actor, order and policy version. This changes input context, schema and instructions. It does not isolate a prompt effect and does not retroactively change v1 grades.

## 3. After: inspect the explicitly authored repair

Read [the complete authored v2 answer JSON](examples/authored-v2-repair.json), [the registered rule records](rules.json), and [the complete cases](contract_cases.json). This answer was written by the author to demonstrate the interface; it is **not a provider response**. Its business facts retain ordinary order `LAB-001`, standard order kind, complete proof and current `returns-v3`.

The crucial distinction is a direct atom backed by its proof record versus a derived claim with a rule identity and atomic premise references:

```json
{
  "atomic_claim": {
    "id": "a-proof_status", "field": "proof_status", "value": "complete",
    "evidence_ids": ["proof-check"]
  },
  "derived_claim": {
    "id": "d-eligibility", "field": "eligibility", "value": "eligible",
    "rule_id": "standard-return", "rule_version": "1",
    "premise_ids": ["a-owner_match", "a-tenant_match", "a-order_kind", "a-proof_status", "a-policy_version", "a-policy_current"],
    "evidence_ids": ["policy-rules"]
  }
}
```

This excerpt selects two entries; `atomic_claim` and `derived_claim` are explanatory labels, not submittable top-level members. The full answer contains all other required atoms and top-level members. The exact schema, limits, source checks and gate meanings are specified in [CONTRACT.md](CONTRACT.md).

The `standard-return` rule, version `1`, requires these exact premises:

| Registered premise | Atomic claim ID | Direct source |
| --- | --- | --- |
| `owner_match=yes` | `a-owner_match` | `access-check` |
| `tenant_match=yes` | `a-tenant_match` | `access-check` |
| `order_kind=standard` | `a-order_kind` | `order-record` |
| `proof_status=complete` | `a-proof_status` | `proof-check` |
| `policy_version=returns-v3` | `a-policy_version` | `policy-current` |
| `policy_current=yes` | `a-policy_current` | `policy-current` |

`order_id=LAB-001` is still a required validated atom and scope binding; it is not an extra premise of this registered rule. The derivation must cite `policy-rules` and reference exactly the six matching atomic claim IDs. A trusted policy record, exact version and host registry establish the rule; model-authored prose does not. The `gift-review` rule has `order_kind=gift` instead and concludes `manual_review` for `LAB-005`.

A missing premise, wrong version, false source or unknown rule invalidates the derivation even if the final label happens to be right. A derived claim cannot serve as a premise. Referencing itself, another derivation or an unknown ID fails. There is no recursive proof search. Returning only a stop/deny answer cannot pass required completion for these cases.

## 4. Write your own repair and check it

First run the example report command documented below, inspect the red original grade, and predict the reference result before opening it. Preserve your prediction and the original report. Create `../submissions/repair.json` yourself; keep the grader, cases, registry and runtime unchanged. You may use the complete reference after attempting the repair, but record that assistance.

Use this zero-paid-call check for your own file:

```sh
mkdir -p ../submissions
# Write your own full answer to ../submissions/repair.json before running the check.
../harness-contract-venv/bin/python -B - <<'PY'
import json
from pathlib import Path
from contract_cases import case_by_id
from evidence_contract import grade
answer = json.loads(Path('../submissions/repair.json').read_text())
report = grade(case_by_id('ordinary_complete'), answer)
print(json.dumps(report, indent=2))
raise SystemExit(0 if report['hard_pass'] else 1)
PY
```

A nonzero exit here means your current repair fails; inspect the independent schema, evidence, atomic and derivation gates before editing your submission again. Keep your failed and repaired files and results. A green local result means this authored case satisfies the automatic contract, with prose still `pending_human`.

## 5. Break the proof with the same checker

Read [the full deliberate mutations](examples/broken-mutations.json) alongside [the recomputed example report](examples/example-report.json). These are edited authored answers, not additional provider calls. Compare each mutation with the reference and predict its failing gate. They should expose why a known citation, correct decision or plausible natural-language rule is insufficient. Inspect the supplied mutation names and exact outputs rather than relying on a saved `hard_pass` value.

The supplied nine mutations cover concrete boundaries:

| Mutation | Boundary exposed |
| --- | --- |
| `eligibility_as_atomic` | Schema forbids an eligibility atom |
| `wrong_direct_source` | A known record does not assert this atom |
| `forged_rule`, `wrong_rule_version` | Rule identity/version must be registered |
| `missing_premise`, `unrelated_order_id_premise` | Premise references must match the exact set |
| `self_reference` | A derivation cannot use itself as a premise |
| `decision_disagrees` | Even a valid proof must agree with the decision |
| `all_stop` | Missing derivation cannot pass required completion |

Run the readonly local example command to recompute the original v1 result, authored v2 result and mutation results:

```sh
../harness-contract-venv/bin/python -B examples.py
```

This command and the tests make **0 paid calls**. The checker is fixed across the v2 green reference and v2 red mutations; the red original is separately checked by its original v1 checker. This is not a claim that the same schema accepts both generations.

## 6. Keep fresh paid validation separate

Only after inspecting the local exercise should you consider the optional paid command in [RUN_CONTRACT.md](RUN_CONTRACT.md). It plans two new requests under v2, with no retry, repair, fallback or resume. It uses the same persistent shared project ledger capped at 20 attempts / USD 2 estimated total, including prior requests. The recorded project had 18 attempts before this stage; there is no extra allowance for improving an outcome.

Actual results and the readonly verification procedure belong to [the separate v2 evidence](/research-evidence/harness-contract-v2/README.md). Do not label the authored repair as raw model output or infer the live outcome from its local green result. Request/context/schema bindings, raw responses, usage, reservations, timing and original ledger snapshots must be verified independently of a saved summary. Evidence integrity and task success are separate checks; either actual case may fail and must remain recorded.

Two changed-task observations cannot establish a general model improvement, a reliability rate or production p95. Structured proof checks also do not certify all natural-language semantics, authorize a merchant operation or replace human release review. The [original evidence](/research-evidence/harness-eval/README.md), raw attempt 8 and historical scores remain intact.
