---
title: "Sourced output"
url: https://services.dev/docs/service/sourced
captured: [legal-walk.txt, service-check.txt, service-cite.txt, tax-check.txt]
---
# Sourced output

URL: https://services.dev/docs/service/sourced

> cite 'source' makes every field a step outputs carry the file and page it came from, and the review fails a field that doesn't trace.

`cite: 'source'` answers one question: where did each value come from?

## Smallest form

```ts title="services/term-list.ts"
  deliver: { terms: { by: 'ai', cite: 'source' } },
```

```bash
npx services.dev check
```

```txt title="magic values: none"
  steps   terms · ai · cites source → review · ai · adversarial
```

## Every form

**On a work step**

| Key | Written | Left out | Does |
|---|---|---|---|
| `cite` | `'source' \| (string & {})` | none | 'source': every output field cites the input it rests on, and the review fails a field that doesn't. A string: the authority a calculation follows, recorded on the line. |

## Every field carries its source

A cited step's fields arrive as `{ value, source }`, where the source names the input file and the page. The review fails a field that doesn't trace back:

```bash
curl http://localhost:8787/jobs/job_7Hq3   # its output
```

```json title="magic values: none"
{
  "terms": {
    "value": [
      "Simulated terms 1",
      "Simulated terms 2",
      "Simulated terms 3"
    ],
    "source": {
      "file": "lease.pdf",
      "page": 1
    }
  }
}
```

On localhost the simulated AI cites the first file the order sent, at page 1. Wire your model, and it names the page it read.

The step's line on the record carries `"cite": "source"`, so the [evidence bundle](https://services.dev/docs/service/evidence.md) shows which output was cited.

## A cited calculation

To record the rule a calculation follows, rather than the document a value came from, give `cite` a string. See [your code as a step](https://services.dev/docs/service/code.md).

## Seven surfaces

No call of its own: it changes what the job carries, on every surface that reads one.

[Operations](https://services.dev/docs/reference/operations.md) has every column of every row.

## Refusals

None of its own.

## In the example brands

The lines that use it in the example brands, as their files write them, and what `check` read aloud for each file.

```ts title="legal · services/demand-letter.ts · 26 lines"
// The draft doesn't cite here: under cite: 'source' every output field is { value, source }, which the
```

```txt title="npx services.dev check · captured/legal-walk.txt"
services/demand-letter.ts · 26 lines · $149 per job, within 48 hours, charged on send's receipt.
  steps   consent · client · consent → draft · ai → attack · ai · adversarial · 3 lenses → sign · attorney · client · stamped · 2-item checklist → send · the recipient → courier · a courier · routed → reply · ai → settle · client · decide
```

[The legal example](https://services.dev/docs/examples/legal.md) runs every one of its files, captured.

```ts title="tax · services/estimate.ts · 17 lines"
    compute: { by: estimateFor, cite: 'prior-year safe harbor, cumulative by quarter' },
```

```txt title="npx services.dev check · captured/tax-check.txt"
services/estimate.ts · 17 lines · $79 per job, within 48 hours, charged on delivery.
  steps   compute · code · cites prior-year safe harbor, cumulative by quarter → approve · owner · decide → review · ai · adversarial → pay · Treasury and states · one for each jurisdiction with an installment → record · code
```

[The tax example](https://services.dev/docs/examples/tax.md) runs every one of its files, captured.

---

- Up: [Service()](https://services.dev/docs/service.md)
- Previous: [Your code as a step](https://services.dev/docs/service/code.md)
- Next: [Another Service as a step](https://services.dev/docs/service/nested.md)
