> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nika.sh/llms.txt
> Use this file to discover all available pages before exploring further.

# Receipts and verification

> Keep the engine-issued receipt, hand it back unchanged, and read what the engine's verdict proves on each transport.

Every run writes a hash-chained record. The result hands your code a
**receipt**, an engine-issued pointer to that record, and
`nika.traceVerify(receipt)` asks the engine to check the record against it.
The SDK never reads a trace or does cryptography itself.

```ts verify.mts theme={"system"}
import { Nika, isNikaRunSucceeded } from '@supernovae-st/nika'

const nika = new Nika({ cwd: process.cwd() })
const run = await nika.run('hello.nika')
const result = await run.result()
if (!isNikaRunSucceeded(result) || !result.receipt) throw new Error(`run ended ${result.status}`)

const proof = await nika.traceVerify(result.receipt)
console.log(proof.verified, proof.verdict, proof.reason ?? '')
console.log('sealed:', result.receipt.sealed, 'trace:', result.receipt.trace_path)
```

```text theme={"system"}
true verified
sealed: true trace: .nika/traces/2026-10-24T10-33-15Z-72de.ndjson
```

That is a machine with a run-signing key in `~/.nika/keys/`
([quickstart step 2](https://docs.nika.sh/sdk/start/quickstart.md)). Without one, the same run
succeeds and prints `false invalid receipt_mismatch` and `sealed: false`.

<video controls muted playsInline preload="none" poster="/images/posters/sdk-admitted-executed-sealed.png" aria-label="node gate.mts refuses list-files.nika, which runs ls under permits: {}, with NIKA-SEC-004 and never starts it, and a one-line permits fix runs it; node prove.mts on a machine with no signing key prints sealed false and receipt_mismatch, then after NIKA_KEYCHAIN=off nika key init prints sealed true and verified; node tamper.mts changes one byte of the trace, and node verify.mts prints not verified and the engine's BROKEN at line 5" alt="node gate.mts refuses list-files.nika, which runs ls under permits: {}, with NIKA-SEC-004 and never starts it, and a one-line permits fix runs it; node prove.mts on a machine with no signing key prints sealed false and receipt_mismatch, then after NIKA_KEYCHAIN=off nika key init prints sealed true and verified; node tamper.mts changes one byte of the trace, and node verify.mts prints not verified and the engine's BROKEN at line 5">
  <source src="https://mintcdn.com/supernovae-acdf3706/BQMaEHUNhf9JYml1/videos/sdk-admitted-executed-sealed.mp4?fit=max&auto=format&n=BQMaEHUNhf9JYml1&q=85&s=f6f4fa573c7038750c954f0914033da5" type="video/mp4" />
</video>

**Admitted, executed, sealed: three different facts.** `check()` refuses a file that runs `ls` under `permits: {}` (`NIKA-SEC-004`, with its fix) and `run()` never starts it: no run, events or trace exist. One permits line fixes it. On a machine with no signing key, `prove.mts` runs `hello.nika`: the run succeeds, its receipt reads `sealed false · 5 events` and `traceVerify(receipt)` answers `receipt_mismatch`. After the quickstart's `NIKA_KEYCHAIN=off nika key init` (step 1 in the [SDK README on GitHub](https://github.com/supernovae-st/nika-client#readme), as the comment on screen says), the next run reads `sealed true · 6 events` and `verified`. Then `tamper.mts` changes one byte on line 4 of the trace, and the stored receipt no longer verifies: the engine reports `BROKEN at line 5`. *Recorded in a terminal from `@supernovae-st/nika` 0.123.0 and its bundled engine `nika 0.123.0 (0bfde3765)`; every model call is `mock/echo`, the engine's offline rehearsal model, with no provider key and no network.*

> [accordion] Transcript: every screen of the recording, in order
>
> ```text theme={"system"}
> $ cat list-files.nika                          # a teammate's file: runs ls, permits nothing
> nika: list-files
> model: mock/echo
> permits: {}
> tasks:
>   list:
>     exec:
>       command: ["ls", "-1"]
> outputs:
>   files: ${{ tasks.list.output }}
> $ node gate.mts list-files.nika
> check  refused · exit 2
>        NIKA-SEC-004
>        exec task under a boundary that forbids shells (task `list`) — fix: add "ls" to permits.exec
> run    not started · NIKA-SEC-004 · no run, no events, no trace
> $
>
> ── screen cleared ──
>
> $ diff -u list-files.nika fixed/list-files.nika
> --- list-files.nika     2026-10-24 19:02:08
> +++ fixed/list-files.nika       2026-10-24 19:02:08
> @@ -1,6 +1,7 @@
>  nika: list-files
>  model: mock/echo
> -permits: {}
> +permits:
> +  exec: [ls]
>  tasks:
>    list:
>      exec:
> $ node gate.mts fixed/list-files.nika
> check  clean · exit 0
> run    succeeded · 10 entries listed
> $
>
> ── screen cleared ──
>
> $ node prove.mts                     # this machine has no signing key yet
> run      succeeded · mock(echo) · Say hello from the Nika SDK.
> receipt  sealed false · 5 events · head 0135b1202a1d…
> verify   not verified · invalid · receipt_mismatch
> $ NIKA_KEYCHAIN=off ./node_modules/.bin/nika key init   # quick start, step 1
> run-signing key minted · fingerprint 847bf18789d52318
>   every run on this machine now seals its journal (verify: nika trace verify <file>)
> $ node prove.mts
> run      succeeded · mock(echo) · Say hello from the Nika SDK.
> receipt  sealed true · 6 events · head b69360abfef1…
> verify   verified
> $ node tamper.mts
> changed one byte on line 4 of .nika/traces/2026-10-24T15-02-41Z-7b95.ndjson
> $ node verify.mts                             # later, from the receipt you stored
> verify   not verified · invalid
> engine   BROKEN at line 5 — recorded chain bb6c5faae667604f · computed fe7aa85e4fead3cc
> $
> ```

## What the verdict means

Measured with `@supernovae-st/nika` 0.123.0 on both transports:

| Transport | Signing key | `traceVerify(receipt)` answers |
| - | - | - |
| Local engine | yes | `{ verified: true, verdict: 'verified' }`: the record is sealed and matches the receipt |
| Local engine | no | `{ verified: false, verdict: 'invalid', reason: 'receipt_mismatch' }`: the run succeeded, but its record is unsealed |
| `nika serve` | yes, on the server | `{ verified: true, verdict: 'sealed', reason: 'sealed' }` |
| `nika serve` | no | `{ verified: true, verdict: 'ok', reason: 'unsealed' }`: the chain is intact but unsigned |

Over HTTP, the server runs the CLI verifier on the journal it wrote for the
job and answers in the CLI's words, lower case: `ok`, `sealed`, `anchored` and
`replayed` hold; `incomplete`, `tampered` and `broken` do not; `unavailable`
means the server holds no journal for that job (refused before its first
event, or still queued). The SDK sets `verified: true` only for a verdict that
holds **and** names this receipt's `trace_id`.

> [!WARNING]
>
> `verified: true` therefore means different things on the two doors. When the
> signature matters, require `verdict === 'sealed'` over HTTP, or
> `receipt.sealed === true` with `verdict === 'verified'` locally. Locally,
> `receipt_mismatch` is also the answer for an edited or forged receipt: do
> not read every one as "just unsigned".

## What a receipt carries

Pass a receipt back exactly as you received it.

* **A local receipt** carries `trace_path`, `chain_head`, `chain_len`,
  `sealed`, `trace_id`, `execution_id`, `snapshot_digest` and
  `receipt_format`.
* **A `nika serve` receipt** carries `job_id`, `execution_id`, `trace_id`,
  `snapshot_digest`, `origin` (`{ kind: 'manual' }` for a job your code
  submitted) and `chain_head`. Store it with the job id.

## Keep a local receipt verifiable

A local receipt points at its trace file by a path **relative to the client's
`cwd`**, and that file is subject to retention:

* Verify it from a client with the same `cwd`. From another directory, or
  once the file is gone, `traceVerify(receipt)` answers `verdict: 'invalid'` with
  `exitCode` 3 and no `reason`: the engine cannot read the trace.

* By default the engine keeps the last 10 traces per workflow, at most 30
  days old, within 256 MB. `NIKA_TRACE_KEEP`, `NIKA_TRACE_MAX_AGE_DAYS` and
  `NIKA_TRACE_BUDGET_MB` change the three bounds, and `traces.keep` in
  [`nika.yaml`](https://docs.nika.sh/sdk/project/nika-yaml) sets the age cap. For long-lived
  audit evidence, export a dossier (journal, manifest, receipt and
  `VERIFY.md`) when the run ends:

  ```sh theme={"system"}
  ./node_modules/.bin/nika trace evidence .nika/traces/<run>.ndjson -o evidence/<run>
  ```

  The pack is redacted by default: it proves the run's integrity, not its
  content. `--full` includes the content verbatim.

* Store `receipt.trace_id` and `receipt.execution_id` to identify a run.
  `run.id` is a throwaway id on the local transport.

## Inspect a trace from the command line

```sh theme={"system"}
./node_modules/.bin/nika trace verify .nika/traces/<run>.ndjson   # the same verifier, for people
./node_modules/.bin/nika trace show .nika/traces/<run>.ndjson
./node_modules/.bin/nika trace replay .nika/traces/<run>.ndjson   # re-renders; never re-runs
./node_modules/.bin/nika trace export .nika/traces/<run>.ndjson   # OTLP spans
```

A verified record proves the record is intact and matches the receipt. It
does not prove that the workflow was right, or that a person read its output:
it is tamper-evident, not tamper-proof. [Traces](https://docs.nika.sh/concepts/traces.md) explains the
evidence tiers.

> [accordion] Which version is this?
>
> > [!NOTE]
> >
> > These pages describe the published `@supernovae-st/nika@0.124.4`
> > [SDK release](https://github.com/supernovae-st/nika-client/tree/v0.124.4) and its matching
> > [bundled engine](https://github.com/supernovae-st/nika/releases/tag/v0.124.4). A newer engine
> > release or SDK main commit does not change an installed package. Use Node.js
> > 22 or newer, on macOS (arm64, x64) or Linux with glibc (x64, arm64); no
> > global Nika installation is required for local mode. Versioned transcripts,
> > recordings and measurements keep the release they were captured on;
> > selecting this package release does not re-run those examples.

> [card] [Run receipts pattern](https://docs.nika.sh/patterns/run-receipts.md)
>
> Carry receipts through application boundaries.

> [card] [Traces](https://docs.nika.sh/concepts/traces.md)
>
> The journal under the receipt.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.