# Harness Journey: one return across five engineering boundaries

Follow one fictional return request through an authored model failure and chosen backup, current evidence and proposal, reviewer approval, queued execution, a merchant commit whose response disappears, a workflow upgrade and receipt-based recovery. The task is `journey-return`. Creating a return request does not refund money.

This is a Python 3.10+ standard-library lab for readers who can follow JSON, HTTP and SQLite. It starts real local child processes, uses real loopback HTTP and persists SQLite files. Both model outputs and failure events are authored offline fixtures; **provider calls = 0**. Approval uses a fixture reviewer. Synthetic execution units are not provider tokens or money.

[中文说明](README.zh.md) · [Walkthrough](WALKTHROUGH.md) · [Repair exercises](EXERCISES.md) · [Exact CLI contract](CLI_CONTRACT.md)

## Start with the complete route

Download the [source ZIP](https://ai.lwkjob.com/downloads/harness-journey-v1.zip), extract it, and enter the directory containing `journey.py`. Keep the code, SQL, fixture and provenance files together. Loopback networking must be allowed. Choose a fresh work directory for each `demo`, `scenario` or `grade`; reusing an existing ledger is deliberately refused.

```sh
python3 -B journey.py demo --work /tmp/journey-demo
python3 -B journey.py verify --work /tmp/journey-demo
python3 -B journey.py inspect --work /tmp/journey-demo --task-id journey-return
```

The demo follows the interrupted path through completion. The verifier rereads storage and source fingerprints; a saved `report.json` is a navigation aid, never proof that the run passed. Read the reported assertion failures before changing anything. Exit 0 means command completion, or that a scenario observed its expected rejection. Exit 1 means a grade/verification assertion failed; exit 2 means usage or setup failure. The deliberate crash child exits 75 and its parent checks that exit.

[![One return through five boundaries](figures/journey-flow-en.svg)](figures/journey-flow-en.svg)

*Authored process diagram, not a run transcript. [Open full size](figures/journey-flow-en.svg). Observed evidence is linked separately below.*

## Stop at the uncertainty boundary

```sh
python3 -B journey.py scenario --name lost_response --work /tmp/journey-stop --stop-after-unknown
python3 -B journey.py verify --work /tmp/journey-stop
python3 -B journey.py inspect --work /tmp/journey-stop --task-id journey-return
python3 -B journey.py resume --work /tmp/journey-stop
python3 -B journey.py verify --work /tmp/journey-stop
```

The stop command exits 0 because it reached the requested checkpoint. The first `verify` must exit 1: the merchant committed, but the controller has not reconciled and settled. Preserve that output. `resume` reuses this directory and the original business operation key, then upgrades the persisted workflow and queries the receipt. The final `verify` must exit 0. Do not delete the merchant ledger or mint another operation key to make an unknown result look new.

[![Recover an unknown write from authoritative evidence](figures/recovery-sequence-en.svg)](figures/recovery-sequence-en.svg)

*Authored recovery sequence. [Open full size](figures/recovery-sequence-en.svg). Receipt lookup establishes the original effect; changing the worker does not erase it.*

## Make the learner baseline red, then repair it

```sh
python3 -B journey.py grade --work /tmp/journey-starter --student settlement_student.py
```

The supplied starter deliberately raises `NotImplementedError` at `decide_settlement(payload)`. A failed grade is the expected baseline, not an installation failure. Preserve it and implement the function in a separate copy. [EXERCISES.md](EXERCISES.md) gives the payload contract, diagnostic steps and reference-assisted repair. Keep the same grader and cases after repair. You can inspect the guided reference directly:

```sh
python3 -B journey.py grade --work /tmp/journey-reference --student settlement_reference.py
```

This is a guided authored exercise. Running the supplied reference is not evidence that an independent learner solved an unseen problem.

## Five checkpoints on the same task

| Topic | Required fact | What to inspect next |
| --- | --- | --- |
| Tenant fairness | Admission reserves capacity and budget atomically; a held unknown still consumes capacity | Persisted queue/cursor and reservations, not just a printed schedule |
| Durable reducer | Original event identity returns its committed receipt without moving current state backward | Event identity, sequence, digest and saved receipt |
| Workflow upgrade | v1→v2 preserves the original operation key, approval and consumed units | Before/after envelope, epoch and rollback evidence |
| Model fallback | Only the classified transient fixture can switch once to a capable backup; subsequent Agent turns stay bounded | Attempt source, complete task facts, capabilities and allowance |
| Tool contract | Evidence accepts a proposal; approval authorizes it; the merchant receipt proves its effect | Selected evidence, proposal hash, current authority and receipt binding |

The workflow, merchant authority and runtime reservation tables share `shared.sqlite`. The Agent checkpoint lives separately at `tasks/journey-return.sqlite`. `run.json` binds run metadata and source fingerprints. `report.json` records observations. This is a single-host design, with runtime and merchant sharing one SQLite authority file; it does not demonstrate distributed fencing across independent services. See the [storage map](WALKTHROUGH.md#storage-map) before editing a database.

## Run a focused fault

```sh
python3 -B journey.py scenario --name replay_conflict --work /tmp/journey-replay
python3 -B -m unittest discover -v
python3 -B package.py --out /tmp/harness-journey.zip
```

Other scenario names are `fair_queue`, `migration_rollback`, `stale_worker`, `fallback_blocked`, `evidence_missing`, `forged_receipt` and `lost_response`. Each completes the same return journey after its focused diagnostic, except when you explicitly stop `lost_response` at unknown. A scenario's exit 0 can mean an unsafe action was rejected correctly. It does not mean the unsafe proposal succeeded.

The package allowlist excludes work databases, run reports, caches and private files. `MANIFEST.json` lists packaged files; the runtime fingerprint covers executable Python/SQL and provenance. Preserve historical evidence, and use a fresh work directory after changing source.

## What these checks establish

They exercise local admission, transactional persistence, replay identity, semantic migration, bounded offline routing, authority checks, response-loss recovery and storage-derived acceptance under declared fixtures. Request round-robin is not a proof of time/cost fairness for arbitrary workloads. Reducer transactions cannot undo a remote effect. No real provider quality, production throughput, distributed failover or learner success rate is measured.

Read the [practical article](https://ai.lwkjob.com/en/notes/harness-end-to-end-project/) for the five-course route. The release's source-bound evidence is published under [the evidence index](https://ai.lwkjob.com/research-evidence/harness-journey/README.md); compare its exact argv, exits and source hashes before reusing a claim.

The frozen release run used **Python 3.12.14**: [all eight scenarios verified](https://ai.lwkjob.com/research-evidence/harness-journey/scenarios.json), [19 regression tests passed](https://ai.lwkjob.com/research-evidence/harness-journey/tests.log), and [independent final verification passed](https://ai.lwkjob.com/research-evidence/harness-journey/demo-verify.json). The recorded starter grade fails and the reference grade passes; these are authored baseline/reference outcomes. Python 3.10 is the declared minimum, not a claim that every OS/Python combination was tested.
