---
title: "nova replay, diff and diagnose commands"
description: "Reference for nova replay and its modes, nova diff between two run capsules, and nova diagnose, which attributes a failed run to its most likely step."
canonical: https://novafabric.ai/docs/cli-reference/replay-and-diff/
last_updated: 2026-11-21
source: https://github.com/MSKazemi/novafabric/blob/main/docs/cli-reference.md
---

# nova replay, diff and diagnose commands

Part of the [NovaFabric CLI reference](https://novafabric.ai/docs/cli-reference/). Both `nova` and `novafabric` run the same binary.

What each of the five modes reuses from the capsule, and what still runs live, is explained in [Replay modes for AI agent runs](https://novafabric.ai/docs/architecture/replay-modes/).

## Replay commands (v0.3)

### nova replay \<capsule\>

Replay a captured run. `<capsule>` is either the **run id** `nova capture` printed, or a
path to the capsule directory. A path that exists is always used as given; only a
reference that is not a usable path is looked up as a run id, in
`$NOVAFABRIC_CAPSULE_DIR` (default `~/.novafabric/capsules/`). Since v0.105.0
the lookup also covers the framework-adapter defaults — `$NOVAFABRIC_HOME/runs/` and
`./.novafabric/runs/` — announcing on stderr where the capsule was found, and failing
with every matching path listed if the id exists in more than one of them (see
§Framework Adapters, "Where adapter capsules land").

```bash
# By run id — what `nova capture` hands you
nova replay 01HXAY7M5JZ8R7K4P9DPBYK2WX --mode forensic

# By path — including the ./.novafabric/runs/ the in-process SDK writes to
nova replay .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --mode forensic
nova replay .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --mode mocked
nova replay .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --mode semantic
nova replay .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --mode exact
nova replay .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --dry-run
nova replay .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --output-dir /mnt/replays
```

Options:
- `--mode {mocked,forensic,semantic,exact,intervention}` — replay mode (default: `mocked`). Tab-completion available via `nova --install-completion`.
  `exact` re-executes nothing: it checks whether the recorded run meets the exact-replay preconditions and exits `0` with `eligible for exact replay` when it does. An ineligible capsule (`env.lock` not `deterministic`, an unseeded model call, a non-re-runnable command, schema drift) exits `1` with `status: failure` in `replay_result.yaml` and each reason printed; it was a green tick and exit `0`. `semantic` prints the mean pairwise similarity of the recorded responses; with fewer than two responses there is nothing to compare, so `similarity_score` is absent (it read `1.0`) and `divergence_reason` says why.
- `--dry-run` — report what would execute without running; writes dry-run report and exits 0 — or exits 1, with the same `REFUSED: …` message and `error.type: CapsuleNotReplayable`, when the selected mode is `mocked` and the capsule records no command to re-run (see below), or exits 3 with `ToolOverrideUnenforceable` when a strict mocked replay would refuse to start (see *Per-tool overrides* below). In `mocked` mode each recorded tool call is labelled with exactly what the replay will do (`[MOCK]`, `[MOCK (never live)]`, `[MOCK (override not honoured: needs --allow-…)]`, `[LIVE]`, `[LIVE (override honoured)]`, `[DENY]`), followed by a `Tool overrides (replay.yaml)` table
- `--allow-readonly` — safety-ladder rung: permit `read-only` tools
- `--allow-mutating` — rung for `idempotent-write` and `non-idempotent-write` tools
- `--allow-external-side-effects` — rung for `external-side-effect` tools (implies `--allow-mutating`)
- `--allow-unknown-mutation` — rung for tools with `unknown` mutation class (implies every lower rung). **Every MCP call counts as `unknown`**, whatever class the capsule recorded, so this is the rung MCP calls need
- **Policy gate.** Any of the three write-permitting rungs (`--allow-mutating`, `--allow-external-side-effects`, `--allow-unknown-mutation`), alone or combined, triggers the audited `replay_mutating` policy check before the replay starts, in every mode and with `--dry-run`. A deny, or a policy-engine error, refuses the replay before anything runs. `--allow-readonly` and no flag are not gated. *Unreleased (after v0.105.0):* up to v0.105.0 only `--allow-mutating` triggered the check.
- The four rungs drive the `--dry-run` report. In a `mocked` replay they gate the intercepted tool surfaces (MCP `call_tool`, `record.tool`, Google ADK tools through the tool plugin, and OpenAI Agents function tools through `wrap_tools`) in two places only — ADR-0306, experimental: under `--permissive` an unmatched call runs live only if its class is permitted (`none` always is; a `record.tool` call uses its declared class, an ADK tool the class `make_tool_plugin` declares, an Agents SDK tool the class `wrap_tools` declares), and a `replay.yaml` `allow: true` override re-executes a tool only if its class is permitted. They never stop a tool replay does not intercept.
- `--permissive` — `mocked` mode only (ADR-0300): do **not** fail on divergence. A model call with no recorded response gets an empty reply with a warning (the pre-ADR-0300 behaviour), unsupported model surfaces run **live**, an unmatched MCP, `record.tool`, ADK or Agents SDK tool call runs live only if a ladder flag permits its mutation class — `--allow-unknown-mutation` for MCP, the declared class for `record.tool`, ADK and Agents SDK tools — and never when `replay.yaml` says `allow: false` (otherwise it is refused and counted in `replay_contract.tool_calls_refused`), and unconsumed recordings are only reported. *Changed in v0.105.0 (ADR-0306 Q3):* `--permissive` alone used to run every unmatched MCP call live. Every divergence is still recorded in `replay_result.yaml` (`divergence_reason`, `replay_contract.divergences`) and `--permissive` is listed in `policy_flags_used`. Exit 1 with any other mode.
- `--output-dir, -o PATH` — base directory for replay output (default: `$NOVAFABRIC_HOME/replays/`, the directory `nova init` creates; up to v0.106.0 it was `./.novafabric/replays/` under the current directory)
- `--environment ENV` — experimental (ADR-0126): only replay a capsule that recorded `ENV` as its `deployment_environment` (exact match, case-sensitive). Otherwise exit 2 before anything runs; a capsule with no recorded environment is refused. Usable as a CI gate, e.g. `nova replay --environment staging --dry-run <run-id>`. The `replay_mutating` policy input also carries the recorded value as `input.resource.deployment_environment` (`null` when absent).
- `--intervention-file PATH` — InterventionSpec YAML for `--mode intervention` (experimental, ADR-0086): one target selector (`event_index` or `span_id`) + exactly one substitution (`replace_model_response` / `replace_tool_result` / `mutate_payload`) + optional named check-functions (`fatal: true` aborts). The output capsule is diffable against the baseline with `nova diff`. Only a `model-calls` substitution reaches the re-executed workload; a `tool-calls` one changes the output capsule and the checks only (tools run live), which the result records as `intervention.substitution_delivered_to_workload: false` and the CLI reports as a warning. `replace_model_response` is the response text (`"DENY"`), a message (`{content: …, tool_calls: …, finish_reason: …}`) or a list of choices; it replaces the record's `gen_ai.response.choices`, which is what replay serves (any other shape is refused). A check's `field` is a dotted path into the record, where a number indexes a list: `gen_ai.response.choices.0.message.content`. Releases up to v0.107.0 wrote the value to a `response` field replay never read, so the re-run was served the recorded answer although the result said the substitution was delivered.

**Mode contracts:**

| Mode | Re-executes command? | Re-executes models? | Re-executes tools? | Output |
|---|---|---|---|---|
| `forensic` | No | No | No | Inspection report |
| `mocked` | Yes (Python workloads) | OpenAI `chat.completions` and Responses API, Anthropic `messages` — sync or async, streamed or not: from the capsule. `parse`, legacy completions, Anthropic `messages.stream()`, `with_raw_response`: refused (live with `--permissive`). Other providers: live, connections reported | MCP `ClientSession.call_tool`: from the capsule, unmatched calls refused (live with `--permissive` only with `--allow-unknown-mutation`). Functions declared with `novafabric.capture.record.tool` (experimental, ADR-0306): from the capsule before the body runs, unmatched or unservable calls refused (live with `--permissive` only if an `--allow-*` flag permits the declared mutation class). Every other tool: **live** | Replay result with served/unmatched counters and any divergence |
| `semantic` | No | No | No | Similarity score (0–1.0) across model call responses |
| `exact` | No | No | No | Eligibility check: deterministic env + seeded calls |
| `intervention` | Yes | Substituted + recorded (warn on divergence) | **Live** (no tool dispatcher) | Counterfactual capsule marked `replay_mode: intervention` (experimental, ADR-0086) |

`mocked` is **fail-closed** (ADR-0300): an extra model call, a provider or order
mismatch, an unsupported model surface, an unmatched MCP or `record.tool` call, a
`record.tool` record that cannot be served, or a recorded
response that is never requested makes the replay `failure` (exit 1) with a
`divergence_reason` — even if the workload caught the error and exited 0. See the
[support matrix](https://novafabric.ai/docs/architecture/replay-modes/#support-matrix).

**Capsules with no command to re-run.** A capsule written by a framework adapter or
the `@agent` decorator (`novafabric.sdk.agent`; `capture_mode: sdk-decorator`, `command` is a label
such as `@langgraph:demo`), one imported from OpenTelemetry spans (`otel-import`), or
one with an empty `command` cannot be re-run. `mocked` refuses it before anything is
spawned: `status: aborted`, `error.type: CapsuleNotReplayable`, exit 1 (also under
`--dry-run`). `intervention` emits the counterfactual streams without re-running and
records `intervention.downstream_reexecuted: false`. `exact` reports it not eligible.
`forensic` and `semantic` work as for any capsule. See
[which capsules each mode accepts](https://novafabric.ai/docs/architecture/replay-modes/#which-capsules-each-mode-accepts).

**Per-tool overrides** (experimental, since v0.105.0, ADR-0306). A capsule's `replay.yaml`
`tool_overrides` (`{tool_name, allow}`, or the legacy `action: replay|refuse`) are
enforced inside the replayed `mocked` process on both intercepted surfaces. A restriction
from the capsule holds and a permission needs the operator: `allow: false` is never run
live, even under `--permissive` (a recorded result is still served); `allow: true`
re-executes the tool only with the `--allow-*` flag for its class, otherwise the
recorded result is served and `override_not_honoured` is reported. An `allow: false`
on a tool recorded on a transport replay cannot intercept cannot be enforced: a strict
replay refuses to start (`status: aborted`, `error.type: ToolOverrideUnenforceable`,
exit 3, also under `--dry-run`); `--permissive` starts and reports an
`override_unenforceable` divergence. Each override's outcome is written to
`replay_contract.tool_overrides`.

**Exit codes:** `0` — replay succeeded, or a `--dry-run` the real run would not refuse ·
`1` — replay failed or was aborted (a divergence under the fail-closed default,
`CapsuleNotReplayable`, a replayed command that could not be launched —
`error.type: ReplayLaunchError` — a fatal intervention check) or a usage
error · `2` — `--environment` did not match the capsule's recorded environment · `3` —
`mocked` refused to start because a `replay.yaml` `allow: false` override cannot be
enforced (`ToolOverrideUnenforceable`, also under `--dry-run`) · `124` —
`mocked`/`intervention`: the replayed command did not finish within 600 s and was killed
(`error.type: ReplayTimeout`, printed and recorded in the replay result) · any
other non-zero value — `mocked`/`intervention` pass through the replayed command's own
exit code. A command that itself exits `124` also yields `124`, but with no
`ReplayTimeout` error; `error.type` is what tells the two apart.

Output is written to `$NOVAFABRIC_HOME/replays/<replay-ulid>/replay_result.yaml`.

```
✓ Replay written: /home/you/.novafabric/replays/01HXBM1Y3K2NGH9V0RD9P0ZDC4  (replay_id=01HXBM1Y3K2NGH9V0RD9P0ZDC4  mode=mocked)
  model calls: 2 of 2 served from the capsule, 0 unmatched
  tool calls (MCP call_tool, record.tool, ADK, Agents SDK): 2 of 2 served, 0 live, 0 unmatched; 0 recorded on surfaces replay does not intercept
  network: 0 live connections from the replayed process — observed, not blocked
```

---

### nova diff \<capsule-a\> \<capsule-b\>

Structurally compare two run capsules. Smart-routed: if both arguments contain `@`,
falls back to the asset registry diff (v0.1 behavior).

Each argument is either a **run id** or a capsule directory path, resolved the same way
as [`nova replay`](#nova-replay-capsule).

```bash
nova diff 01HXAY7M5JZ8R7K4P9DPBYK2WX 01HYBZ8N6KA9S8L5Q0EQCZL3XY
nova diff ~/.novafabric/capsules/01HX.../ ~/.novafabric/capsules/01HY.../
nova diff cap-a/ cap-b/ --output-format json
nova diff cap-a/ cap-b/ --json            # identical to --output-format json
nova diff cap-a/ cap-b/ --output-format github-annotation
nova diff cap-a/ cap-b/ --assert-no-regressions
nova diff --group-by variant runs/arm-a/ runs/arm-b/
nova diff --group-by environment runs/prod-01/ runs/staging-01/
nova diff --environment production cap-a/ cap-b/
nova diff cap-a/ cap-b/ --graph-shape
nova diff cap-a/ cap-b/ --assert-same-shape
nova diff my-agent@v1.0 my-agent@v1.1 --output-format json
```

Environment gating, as run against a temporary `NOVAFABRIC_HOME` (capsule A captured with
`--environment production`, B with `--environment staging`):

```text
$ nova replay <A> --environment staging
replay refused: --environment staging required, but .../<A> recorded 'production'
$ echo $?
2
$ nova diff --group-by environment <A> <B>
Environment groups (ADR-0126, recorded deployment_environment):
  production: .../<A>
  staging: .../<B>
Cross-environment diff: production → staging
$ nova diff --environment production <A> <B>      # B recorded 'staging'
--environment production: .../<B> recorded 'staging'; both capsules must have ...
$ echo $?
2
```

Options:
- `--output-format {text,json,github-annotation}` — output format (default: `text`). Applies to capsule and `name@version` asset diffs alike. Tab-completion available via `nova --install-completion`.
- `--json` — exactly `--output-format json`, in every mode (capsule, `name@version`, `--media`, `--significance`). Combined with an explicit `--output-format text` or `github-annotation` it is a usage error (exit `2`). `--media` and `--significance` take `text` or `json` only; `--output-format github-annotation` with either is a usage error.
- `--assert-no-regressions` — exit 1 if the comparison finds any difference (a changed, added or removed entry in any section); the CI gate. See the exit codes below
- `--group-by variant` — **experimental** ([ADR-0116](https://novafabric.ai/docs/decisions/)). Group the two capsules by their **recorded** A/B-variant attribution — the `(experiment_id, variant_id)` of the optional `variant` block — and label the diff as cross-arm (different groups) or within-arm (same group). A capsule without a `variant` block groups under `(no variant)`. Read-only over recorded facts: this never assigns variants and never mutates a capsule. Capsule paths only; `text`/`json` output only (`json` wraps the report in `{variant_groups, cross_arm, diff}`).
- `--group-by environment` — **experimental** ([ADR-0126](https://novafabric.ai/docs/decisions/) P2). Group the two capsules by their **recorded** `deployment_environment` (the typed top-level field set by `nova capture --environment` / `NOVAFABRIC_ENVIRONMENT`) and label the diff cross-environment or within-environment. A capsule with no value — or one violating the `^[A-Za-z0-9._:-]{1,64}$` rule — groups under `(no environment)`; nothing is inferred. `json` wraps the report in `{environment_groups, cross_environment, diff}`. Same restrictions as `--group-by variant`.
- `--environment ENV` — **experimental** ([ADR-0126](https://novafabric.ai/docs/decisions/) P2). Only compare capsules that both recorded `deployment_environment == ENV` (verbatim, case-sensitive). Fails closed: **exit 2** naming each capsule that recorded another value or none. An `ENV` outside the value rule is a usage error. Capsule paths only; not combinable with `--media`/`--significance`. `json` output adds `environment_filter`. To *list* capsules by environment use `nova query --where 'deployment_environment = production'` — `nova list` lists registry assets, which carry no deployment environment.

- `--graph-shape` — **experimental** ([ADR-0124](https://novafabric.ai/docs/decisions/) P3). Rebuild both capsules'
  agent execution graphs (as `nova graph agent`) and append an additive `graph_shape` block:
  `same shape`, `shape changed` (node/edge deltas by structural path, e.g.
  `span:agent.turn[0]/tool_call:git[0]`, with record ids; capped at 50 per list with true
  totals), or `graph unavailable` with a reason. Reports each side's `graph_digest` (equal only
  for byte-identical graphs — it binds capsule id, record ids and timings) and an id/timing-
  independent `shape_digest` that decides "same shape". In `json` the block is a top-level
  `graph_shape` key; in `github-annotation` one `notice`/`error`/`warning` line. Never fails
  the diff. Capsule diffs only; not combinable with `--media`/`--significance`.
  Reconstruction is best-effort: a line of `model-calls.jsonl`, `tool-calls.jsonl` or
  `trace.jsonl` that is not JSON, or not a JSON object, is skipped. Each built side reports
  those lines per file in `graph_shape.a|b.skipped_malformed_lines`
  (`{"model_calls", "tool_calls", "trace"}`, zeros included; `{}` on an unavailable side).
  Any non-zero count gets a `warning: graph shape: skipped N malformed line(s) in … of run A|B`
  line on stderr, a line in the text block and a `::warning` annotation, and the shape then
  covers only the records that parsed ([ADR-0303](https://novafabric.ai/docs/decisions/) Amendment 2). A source file
  that cannot be read or is not UTF-8 makes that side `graph unavailable`.
- `--assert-same-shape` — **experimental**. Implies `--graph-shape`; CI gate on the shape.
  Exits `2` when a graph is unavailable **or** either side skipped a malformed source line,
  checked before the shape verdict, so a shape over partial records is never certified as the
  same (`0`) or reported as a change (`1`).

Exit codes (capsule and `name@version` asset diffs, [ADR-0303](https://novafabric.ai/docs/decisions/)):

| Code | Meaning |
|---|---|
| `0` | The comparison was made and found no difference — or found one, but no gate flag was given (the diff only reports) |
| `1` | The comparison was made and found a difference: `--assert-no-regressions` saw a changed, added or removed entry in any section (checked first), or `--assert-same-shape` saw a shape change. `1` means nothing else |
| `2` | The comparison could not be made: a capsule ref that does not resolve, an unreadable or malformed `capsule.yaml` or `env.lock` (with or without a gate flag; see below), an asset ref not in the registry, a usage error, `--environment` excluded a capsule, `--assert-same-shape` could not build a graph for either capsule or skipped a malformed graph-source line (fail closed, checked before the shape verdict), or `--assert-no-regressions` read a capsule with malformed record lines (checked before any difference; see below) |
| `3` | `--significance` only: a significant regression (SPRT `accept_h1`) |

A gate that only needs "pass or fail" can test for non-zero; one that must tell "the runs
differ" from "there was nothing to compare" tests for `1` and `2`. Before ADR-0303 an
unresolvable capsule ref or unknown asset ref exited `1`, the same code as a difference. The
same table is printed by `nova diff --help`. `--graph-shape`/`--assert-same-shape` only append
a block; without them, no graph-shape output appears.

The `json` report carries the gate's verdict as a top-level boolean `has_changes`, so a CI step
that keeps `diff.json` reaches the same answer as `--assert-no-regressions` without re-deriving
it from the counts. Each model-call pair also carries `provider_changed`, `params_changed` and
`changed_params` (the sorted `gen_ai.request.*` parameter names that differ).

Diff sections: environment (Python, OS), model calls (logical calls only — the wire hook's
`transport` records under an SDK call are not paired, so one changed prompt is one changed
pair, ADR-0305; a `parent_span_id` unique on both sides first, then sequence position anchored on identical requests; a pair is changed when the
provider, request model, messages, any recorded request parameter or the response choices
differ — the parameters are every other `gen_ai.request.*` attribute capture recorded
(`temperature`, `top_p`, `top_k`, `max_tokens`, `seed`, `stop_sequences`, the penalties,
`choice.count`), and one recorded on one side only counts as changed, [ADR-0303](https://novafabric.ai/docs/decisions/)
Amendment 2), tool calls (exact
`tool_name` + argument hash, each call used once, then position with the same tool name),
and output files — every regular file under `outputs/`, recursively, keyed by its
capsule-relative path (`outputs/reports/summary.json`) and compared by SHA-256. Symlinks under
`outputs/` are skipped and never followed, the same rule the sealed evidence digests use.

"Any difference" has one definition — a changed, added or removed entry in any section — and
every surface uses it: `--assert-no-regressions` exits 1 on it, the `text` output prints
`No differences found.` only without it, and `github-annotation` emits every line at
`error` level when it holds (an added- or removed-only diff included) and a single `notice`
when it does not. Annotation messages escape `%`, CR and LF (`%25`, `%0D`, `%0A`), so a
workload-chosen file name or tool name cannot start a second workflow command.

**Malformed record lines are never skipped silently** ([ADR-0303](https://novafabric.ai/docs/decisions/) Amendment 1).
A non-blank line of `model-calls.jsonl` or `tool-calls.jsonl` that is not UTF-8, not JSON, or
JSON that is not an object takes no part in the comparison, so the diff is incomplete. Each
such file gets a `warning: skipped N malformed line(s) in … of run A|B (…)` line on stderr in
every output format; the `text` report lists them under `Skipped (not compared):` and says
`No differences found in the records that parsed; the comparison is incomplete.` instead of
`No differences found.`; `github-annotation` adds one `::warning` line per file; and `json`
always carries the counts per side and file:

```json
"skipped_malformed_lines": {
  "a": {"model_calls": 0, "tool_calls": 0},
  "b": {"model_calls": 2, "tool_calls": 0}
}
```

Without a gate flag the diff still exits `0`. Under `--assert-no-regressions` it exits **`2`**,
"cannot compare", before `has_changes` is consulted: a skipped line can be the very record an
"added" or "removed" entry on the other side would have paired with, so neither "the runs
differ" (`1`) nor "they do not" (`0`) is established. Repair or re-capture the capsule.

**An unreadable or malformed `capsule.yaml` or `env.lock` is "cannot compare"**
([ADR-0303](https://novafabric.ai/docs/decisions/) Amendment 2). When either file exists but cannot be read, is not
UTF-8, is not YAML, or has a top level that is not a mapping — or when two differing `env.lock`
files have a `python`/`host` section that is not a mapping — `nova diff` prints one line on
stderr and exits **`2`** in every output format, with or without a gate flag, and prints
nothing on stdout:

```text
cannot compare: runs/run-02/env.lock: not valid YAML at line 2, column 1. Repair or re-capture the capsule (exit 2).
```

A missing or empty file is still read as absent (older capsules lack fields). Unlike a
malformed record line, which leaves the rest of the comparison meaningful, these files say
which run it is and what it ran on, so no partial report is printed. `GET /api/diff` answers
`422` with the same message. Before, the parse error escaped as a traceback, which Python
exits with `1`, the "found a difference" code.

**Asset refs.** With two `name@version` refs the command compares the two registered specs
field by field (nested keys flattened to dotted paths). `--output-format` applies: `json` is
the document `nova asset diff --output-format json` emits — `ref_a`, `ref_b`, `identical`,
`added`, `removed`, `changed` (`{"from", "to"}` per key) — plus `has_changes`; a key present
on only one side is added or removed even when its value is `null`. `github-annotation` emits
one escaped `::error` line per differing field, or a single `::notice` when there is none.
`text` prints `--- ref_a`, `+++ ref_b` and one `key: before → after` line per field
(`(absent)` for a missing key). `--assert-no-regressions` exits `1` on any differing field in
every format. `--group-by`, `--environment` and `--graph-shape` do not apply to asset refs.

---

## Diagnose commands (gap-006, ADR-0084)

### nova diagnose \<run-id\>

Attribute a **failed** run to its most likely responsible step, and label the failure
with an `AgentErrorTaxonomy` category. Runs *over* the existing lineage / causal graph
plus the captured trace — it reads `capsule.yaml`, `trace.jsonl`, `tool-calls.jsonl`, and
`model-calls.jsonl`, and (when present) the lineage store's parent/child edges. It is
read-only and writes nothing.

```bash
# Diagnose a failed run in the default capsule directory
nova diagnose run-2026-06-11-abc123

# Diagnose a capsule stored elsewhere, as JSON for tooling
nova diagnose run-xyz --capsule-dir ./capsules --output json
```

Options:
- `--capsule-dir PATH` — capsule storage directory (defaults to `$NOVAFABRIC_CAPSULE_DIR`).
- `--output {text,json}` — output format (default: `text`).
- `--intervene` — **experimental (ADR-0101)**: verify the top hypothesis with a
  counterfactual intervention replay and record an evidence-based verdict (see below).
- `--search-root-cause` — **experimental (ADR-0101 §NF-018)**: search for the earliest
  step whose correction flips the outcome (see below).
- `--max-interventions N` — bound on how many causal-root candidates
  `--search-root-cause` will test (default: `8`, hard ceiling: `50`). Only with
  `--search-root-cause`.
- `--replay-dir PATH` — base directory for the intervention replay output
  (default: `$NOVAFABRIC_HOME/replays`). Only with `--intervene` or `--search-root-cause`.

Algorithm (ADR-0084): decompose the run into ordered steps (src-411 module
decomposition); a **coarse pass** scores each erroring step by explicit error signal,
**earliest-root-cause bias** (src-411 — an earlier error outranks a later downstream
symptom), and **causal-depth bias** (src-413 — a downstream `delegated_to`/`spawned`
step outranks its coordinator ancestor); a **fine pass** picks the single responsible
step and labels it.

`AgentErrorTaxonomy` categories: `MEMORY`, `REFLECTION`, `PLANNING`, `ACTION`, `SYSTEM`,
`UNKNOWN`. Scores are **relative ranking weights, not calibrated probabilities**. A run
with no error signal yields `UNKNOWN` and no fabricated culprit (exit 0); an unknown run
id exits 1.

**Hypothesis verification — `--intervene` (experimental, ADR-0101).** For the **top
hypothesis only**, `nova diagnose` auto-synthesizes an `InterventionSpec` (ADR-0086),
replays the capsule counterfactually under mocked semantics (zero-token), and appends a
verification block — hypothesis, intervention applied, original vs counterfactual
outcome, and an **evidence-based verdict, never guessed**:

```bash
nova diagnose run-xyz --capsule-dir ./capsules --intervene --output json
```

- `CONFIRMED` — the intervention replay re-executed the capsule's command and the
  original failure flipped to success (exit code 0).
- `REFUTED` — the re-execution still failed after the intervention.
- `INCONCLUSIVE` — the flip is not measurable; the reason is always recorded (no
  hypothesis, the original run did not fail, the hypothesis class is not auto-mappable,
  the capsule has no re-executable command, or the replay aborted).

The auto-mappable subset in this slice is **model-call hypotheses only**: the corrective
edit clears the error signal at the implicated model call via a `mutate_payload`
substitution. Tool/span/run hypotheses report an honest
`cannot auto-intervene for this hypothesis class` reason. The intervened output capsule
is hard-marked `replay_mode: intervention` and referenced from the verdict block.
Fidelity bound (ADR-0086): the verdict tests control-flow and downstream handling of the
recorded run, not fresh model behavior. Without `--intervene`, `nova diagnose` remains
read-only and its output is unchanged (an unverified hypothesis is never presented as a
proven root cause).

**Counterfactual root-cause search — `--search-root-cause` (experimental, ADR-0101
§NF-018).** Widens `--intervene` from testing only the top hypothesis into a search: it
sweeps the §NF-019 causal-root candidates — already ranked shallowest/earliest-first,
which is exactly the pruning the ADR calls for over a naive linear sweep of every step —
running a bounded number of zero-token intervention replays (default `--max-interventions
8`, hard ceiling `50`) until one confirms an outcome flip. The first `CONFIRMED` candidate
is the decisive root cause; every attempt (confirmed, refuted, or honestly unmappable) is
recorded, so the search itself is auditable, not just its winner:

```bash
nova diagnose run-xyz --search-root-cause --max-interventions 5 --output json
```

Same auto-mappable subset as `--intervene` (model-call hypotheses only). When no
candidate flips the outcome within the bound, the result says so explicitly
(`bounded: true`) rather than silently looking exhaustive. Composes with `--intervene` —
both flags can be passed together.

---
