---
name: writ-verify
description: >-
  Use when the user wants to check a Writ work record — e.g. "verify this
  Writ run", "check this work-record.jsonl is legit", "does this signed
  bundle from <counterparty> check out", or "verify this against their
  pubkey/head attestation." Runs `writ verify` fully offline against a
  pinned public key (and, when available, a pinned head attestation), and
  translates every possible outcome — OK, incomplete, tampered, wrong key,
  unbound identity, revoked signer, truncated export — into plain language.
  A clean result shows the recorded steps were attested by the holder of the
  key and the chain is intact and complete; it never treats that as proof of
  authorization, payment, completion, or quality.
---

# Writ verify

Check a Writ work record — your own, or one handed to you by a counterparty — fully offline, from nothing but the bundle and a public key.

## What you need

- A run directory or an exported bundle (from `writ record export --out`), which holds `work-record.jsonl`, `run.json` (whose terminal commitment binds the end of the chain), and, for a key-signed run, the signer records. A bare `work-record.jsonl` without `run.json`, `--expect-head`, or `--pinned-head` gives `INCOMPLETE` (exit `8`), not `OK`.
- The signer's **public key**, obtained out of band — never trust a key that arrives bundled with the same evidence you're checking. Good sources: `writ keys show` (your own operator), the output of `writ keys show` the operator sent you directly, or a key you pinned earlier. A `head-attestation.json` names the signer's key id, not its public key, so it is not a source for `--pubkey`.
- Optionally, a head attestation to pin against (`--pinned-head`) — the strongest check available.

## Flow

### 1. Confirm you have a trustworthy anchor

Before running anything, be explicit with the human about *where the pubkey came from*. If it came from inside the same bundle you're about to verify, say so — that's a weaker check than a pubkey obtained separately (e.g. from a prior conversation, a published identity record, or the operator directly).

### 2. Run the check

```bash
writ verify <bundle-or-run-dir> --pubkey <hex>
```

Add `--require-identity` if the human needs to know *who* signed, not just that some valid key did. Add `--pinned-head <attestation.json>` if you have one: the chain must then end exactly at the head the signer attested, so a later shortening is detected without typing the head in.

### 3. Interpret the result

| Output | Meaning | What to tell the human |
|---|---|---|
| `OK — verified N receipt(s).` + `Terminal commitment verified...` | Every receipt's signature and hash-chain link checked out, and the chain wasn't truncated. | The record is intact and complete under the pubkey you pinned. State plainly what that does and doesn't show (below). |
| `WARNING: this work record is signed with a dev-ephemeral (throwaway) key...` | The record used a per-run throwaway key, not a persistent operator identity. | This is **not production evidence** — say so explicitly, even if the chain otherwise verifies clean. |
| `WARNING: no signer identity record — the chain is not bound to a named operator...` | The chain verifies, but there's no named operator behind it. | Flag that you can confirm the chain is intact, but not *who* stands behind it, unless `--require-identity` was also passed. |
| `Key chain: reached the signer from the pinned anchor through N verified rotation(s).` | The pubkey you pinned is an older key; Writ walked a signed rotation chain forward to the run's actual signer. | This is expected and fine if the human already trusts the anchor key — say the rotation was verified, not merely asserted. |
| `Pinned head verified — ... the chain ends exactly at <seq>:<hash>.` | A signed head attestation confirms the chain's exact end. | Say the chain ends where the signer attested it does. |
| `INCOMPLETE — N receipt(s) verified, but no terminal commitment is available...` | Exit `8`. Every receipt checked out, but nothing binds the end of the chain, so a shortened record would look the same. | Not `OK`. Ask for the whole run directory or bundle (with `run.json`), or a head to pin with `--expect-head` or `--pinned-head`. Use `--allow-no-terminal-commitment` only if the human accepts a record that cannot rule out truncation. |
| `FAILED — N problem(s) across M receipt(s): ... signature verification failed` | Wrong pubkey, or a genuinely forged/altered record. | Do not assume which — report the exact failure and ask the human to confirm they have the right pubkey before concluding it's fraudulent. |
| `FAILED — ... receiptHash does not match the recomputed canonical hash (tampered field)` | A specific field in a specific receipt was altered after signing. | Report the exact row — this is real tamper detection, not a false positive to explain away. |
| `FAILED — ... was revoked at <time> but N receipt(s) ... were signed at/after that instant` | The signer's key was revoked before (or during) this record, per a revocation the verifier walked to. | The record is not valid evidence past the revocation instant — say so plainly. |
| `FAILED — --require-identity: no signer identity record was found...` | You asked for a named operator and there isn't one. | Not necessarily fraud — many legitimate `dev-ephemeral` runs have no identity. State the distinction. |

Any `FAILED` line is exit code `5`, and `INCOMPLETE` is exit `8`. Never characterize a `FAILED` result as a false alarm or work around it — report it verbatim and let the human decide what it means for their situation.

### 4. State the boundary, every time

Whatever the result, make explicit what verification does and doesn't establish: a clean result shows that the recorded steps were attested by the holder of this key, and that the chain is intact and complete. It does **not** independently establish authorization, payment, completion, or quality: those are the signer's attestations, and the work itself may still be inaccurate or poor.

## Safety rules

- **Never accept a pubkey bundled with the evidence it's meant to authenticate as sufficient on its own.** Ask where it came from if it isn't clear.
- **Report every `WARNING` line, not just the final `OK`/`FAILED`.** A clean `OK` next to a `dev-ephemeral` warning is a materially weaker claim than a clean `OK` with a verified named identity — don't collapse the two into "it checked out."
- **Never soften a `FAILED` result.** Report the exact line(s); don't editorialize about whether it's "probably fine."

## Example

> User: "A partner sent me this Writ bundle and says it proves they did the research. Here's the pubkey they gave me on the call yesterday: `4b2ec6...`."
>
> → `writ verify partner-bundle/ --pubkey 4b2ec6... --require-identity` → `OK — verified 3 receipt(s). ... Signed by <Operator Name> ..., key ... — identity record verified and bound to the chain.` → "This checks out: 3 receipts, signed and hash-chained intact and complete, bound to the identity <Operator Name>, matching the pubkey you got from them directly. It shows that the holder of that key attested these steps; the payments, the completion, and the quality of the research are their attestation, not something the check confirms independently."

## Next

- [writ-run](../writ-run/SKILL.md) — produce a work record of your own.
- Full docs: https://writ.lightningenable.com/docs/guides/keys-and-verification and https://writ.lightningenable.com/docs/troubleshooting
