# Provenance, rescue and receipt

> Who chose the configuration, the fallback used when a run failed, and a recommender's prediction set against what happened.

> **Info:** Added in 0.3. The matching [producer capability](https://orchestrationcontextprotocol.io/specification/0.3/document#producer) for the receipt is `receipt`.

```json
"provenance": { "kind": "designed", "chooser": "loopmath" },
"receipt": {
  "before": {
    "rec": "rec_ex01",
    "fit": "fit_ex_20260923",
    "predicted": {
      "p_success": { "mean": 0.78, "lo": 0.66, "hi": 0.88, "level": 0.8 },
      "cost_usd": { "mean": 2.9, "lo": 1.9, "hi": 4.4 },
      "tokens": { "mean": 900000, "lo": 600000, "hi": 1400000 }
    }
  },
  "after": {
    "cost_usd": 3.52,
    "tokens": 1376000,
    "signals": ["sig_review_2", "sig_tests_ci"],
    "fit_after": "fit_ex_20260923b"
  }
}
```

The values are made up.

## Provenance

`run.provenance` says how the configuration came to run. A `logged` run was observed as it happened, with the configuration the user's habit chose. A `designed` run had its configuration chosen for it, by a recommender, the user or a planner. The difference matters to a learner: logged runs show what a user tends to pick, designed runs are closer to a controlled comparison.

- `kind` (enum, required): logged: the run was observed as it happened, configuration chosen by the user's habit. designed: the configuration was chosen for the run (by loopmath, the user or a planner).

  One of: `logged`, `designed`.

- `chooser` (string): Who chose the configuration.

  Recommended values (open set): `habit`, `loopmath`, `user`, `planner`.

  At most 100 characters.

- `ext` ([Ext](https://orchestrationcontextprotocol.io/specification/0.3/schema#ext))

## Rescue

A workflow's [`control.rescue`](https://orchestrationcontextprotocol.io/specification/0.3/configuration#control) is the plan for a run that ends without acceptance: redo the task with another configuration, hand it to a person, or nothing. `run.rescue` records the fallback that was actually used, and what it cost.

Present when the run ended without acceptance and a fallback was used.

- `kind` (string, required): Recommended values (open set): `configuration`, `person`, `none`.

  At most 100 characters.

- `ref` (string): At most 200 characters.

- `cost_usd` (number)

- `basis` (enum): measured: the fallback ran and was priced. expected: an estimate.

  One of: `measured`, `expected`.

- `ext` ([Ext](https://orchestrationcontextprotocol.io/specification/0.3/schema#ext))

- `run.rescue` is present only when the run ended without acceptance and a fallback was used.
- `basis` is `measured` when the fallback ran and was priced, and `expected` when the cost is an estimate.

## Receipt

A receipt sets a prediction made before the run against what happened. `before` holds what a recommender predicted for this configuration on this task: the chance of an accepted result, the cost in dollars and tokens, and for an exploration pick, what it expected to gain per run and what the exploration would cost. `after` holds the actual cost and tokens, the signals the result was scored on, and how the fit moved.

Predicted against actual. Written only by loopmath (W196 when another producer writes one).

- `before` (object): *properties*

  - `rec` (string): The recommendation id.

    At most 200 characters.

  - `fit` (string): The fit the prediction came from.

    At most 200 characters.

  - `predicted` (object): *properties*

    - `p_success` ([Interval](https://orchestrationcontextprotocol.io/specification/0.3/schema#interval))

    - `cost_usd` ([Interval](https://orchestrationcontextprotocol.io/specification/0.3/schema#interval))

    - `tokens` ([Interval](https://orchestrationcontextprotocol.io/specification/0.3/schema#interval))

  - `gain_per_run` (any): Per-run gain of an exploration pick: &#123;usd, success_pp, cost_pct, score&#125;, or null.

  - `price_usd` (number | null)

  - `payback_runs` (number | null)

  - `ext` ([Ext](https://orchestrationcontextprotocol.io/specification/0.3/schema#ext))

- `after` (object): *properties*

  - `cost_usd` (number | null)

  - `tokens` (integer | null)

  - `signals` (array): The signals the result was scored on (ids or copies).

  - `moved` (any): How the fit moved after this run (written by loopmath).

  - `fit_after` (string | null): At most 200 characters.

  - `ext` ([Ext](https://orchestrationcontextprotocol.io/specification/0.3/schema#ext))

- `ext` ([Ext](https://orchestrationcontextprotocol.io/specification/0.3/schema#ext))

Every predicted quantity is an interval:

A predicted quantity: mean and an 80 percent interval unless `level` says otherwise.

- `mean` (number, required)

- `lo` (number)

- `hi` (number)

- `level` (number): Central coverage of [lo, hi]; 0.8 when absent.

- Only loopmath writes receipts, and a checker warns when another producer writes one ([W196](https://orchestrationcontextprotocol.io/specification/0.3/conformance#w196)). The receipt's contents follow loopmath's model.
- A consumer MAY ignore the receipt.
