nova replay, diff and diagnose commands

Part of the NovaFabric 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.

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").

# 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 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.

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.

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 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):

$ 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:

Exit codes (capsule and name@version asset diffs, ADR-0303):

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 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 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:

"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 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:

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.

# 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:

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:

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

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:

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.