---
title: "nova capture, setup and adapter commands"
description: "Reference for nova init and nova capture: wrap a command without code changes, API and MCP proxies, framework adapters, the warm daemon, distributed runs."
canonical: https://novafabric.ai/docs/cli-reference/capture/
last_updated: 2026-11-21
source: https://github.com/MSKazemi/novafabric/blob/main/docs/cli-reference.md
---

# nova capture, setup and adapter commands

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

## Setup (v0.38)

### nova init

Initialise a local NovaFabric installation (pip install path only — docker-compose is
self-initialising via its entrypoint).

Creates the directory structure under `NOVAFABRIC_HOME` and generates an Ed25519 signing
keypair (used to sign Evidence Bundle exports, `nova export-evidence --key`). Safe to run
multiple times — existing keys are never overwritten unless `--force` is passed.

`nova init` does **not** turn on capsule sealing. It prints `nova seal init` as an optional
next step and reports whether sealing is configured; sealing stays opt-in (ADR-0301).

```bash
nova init                        # uses $NOVAFABRIC_HOME (default ~/.novafabric)
nova init --home /data/nova      # custom home
nova init --force                # regenerate signing keypair (old pair archived)
nova seal init                   # optional next step: local, self-asserted sealing
```

**Options**

| Flag | Description |
|---|---|
| `--home PATH` | Override `NOVAFABRIC_HOME` for this run |
| `--force` | Regenerate the Ed25519 keypair even if one already exists. The old pair is **moved** to `keys/archive/<UTC>/` (mode 700), never deleted, and a warning says Evidence Bundles signed with it verify only with the archived public key. Refused (exit 1) when `novaseal.yaml` signs capsules with that same key — rotate with `nova seal init --force` instead |

**Created paths**

| Path | Purpose |
|---|---|
| `$NOVAFABRIC_HOME/capsules/` | Default capsule storage |
| `$NOVAFABRIC_HOME/keys/signing_key.pem` | Ed25519 private key (mode 600) |
| `$NOVAFABRIC_HOME/keys/signing_key.pub.pem` | Ed25519 public key |
| `$NOVAFABRIC_HOME/replays/` | Replay result storage |

> **Note:** docker-compose users do not need `nova init`.  The container entrypoint
> handles first-boot setup automatically.

---

## Capture commands (v0.2)

### nova capture \<cmd...\>

Wrap a command and record its execution as a replayable run capsule.

```bash
nova capture python train.py --lr 0.001
nova capture -- python -c "import sys; sys.exit(1)"
nova capture --output-dir /mnt/runs python agent.py
```

Options:
- `--output-dir, -o PATH` — base directory for capsule storage (default: `$NOVAFABRIC_HOME/capsules/`)
- `--timeout FLOAT` — wall-clock deadline in seconds for the captured command. Unset, `local`, `docker` and `kubernetes` use 600 s. For `slurm`, `lsf` and `pbs` the value becomes the job's time limit (`--time` in whole minutes, `-W`, `-l walltime=`; an explicit `time`/`walltime` runner option wins); unset, Slurm uses the partition default, LSF `1:00` and PBS `01:00:00`, and NovaFabric stops polling the job after 3600 s. Increase for long-running agents: `nova capture --timeout 3600 python agent.py`
- **When `--timeout` passes**, the runner stops the job before the capsule is sealed, so it cannot keep writing into it: `local` kills the process group, `docker` removes the container (`docker rm -f`), and `slurm`/`lsf`/`pbs` cancel the job (`scancel`/`bkill`/`qdel`). `runner_metadata` records `cancelled` (and `cancel_error` when the cancel failed). Before, batch jobs and containers ran on after the timeout. For `local` the deadline applies to the workload's own exit: a detached child (`setsid`, a daemon it started) that keeps stdout or stderr open neither stretches the run nor turns a success into a timeout — the capsule records the workload's exit code and notes that later output was not captured (releases up to v0.107.0 waited for the pipes to close, recorded `exit_code: 124`, and could block for the detached child's whole life).
- **A seal that fails** (a signing profile is configured, but the TSA is unreachable, the Merkle log is locked, or the manifest gate refuses): the capsule is left unsealed with the reason in `metadata.finalization_error` — as adapter and `@agent` capsules already did — and `nova capture` prints `✗ Capsule not sealed: <reason>` after `Capsule written`; the exit code stays the workload's. Releases up to v0.107.0 printed only `✓ Capsule written` and recorded nothing.
- **Interrupting a capture** (`local` runner): Ctrl-C, or SIGTERM/SIGHUP sent to `nova capture` (a scheduler, `kill`, a closing terminal), is forwarded to the workload's process group; the workload gets 10 s to exit, then SIGKILL, and `nova capture` exits `130` (Ctrl-C) or `128+signal`. Once the workload has stopped, the capsule is finalised as usual — secret scan, redaction proof, `capsule.yaml`, seal if configured — with `status: aborted`, the workload's `exit_code` (130 or 128+signal) and `error.type: WorkloadInterrupted`. A second Ctrl-C during that finalisation abandons it. Releases up to v0.107.0 left the workload running unsupervised and the capsule unfinalised, with the streams it had written unscanned.
- **Interrupting a remote capture** (`slurm`, `lsf`, `pbs`, `docker`, `kubernetes`): the same
  Ctrl-C or forwarded signal cancels the job — `scancel`/`bkill`/`qdel`, `docker rm -f`, or
  `kubectl delete job`. A batch scheduler is then polled (at most every 1 s, up to 6 times) until
  it reports the job stopped; `docker rm -f` returns once the container is gone; a Kubernetes pod
  writes only inside the pod (nothing is copied back), so an accepted delete suffices. Only then
  is the capsule finalised as `status: aborted`, as above, with `runner_metadata.cancelled: true`;
  `nova capture` exits `130` or `128+signal`. A job whose cancel failed, or that still reports
  running, is **left unfinalised** and a warning names it, because it may still write into the
  capsule. A second Ctrl-C during the cancel stops at once.
  An interrupt during submission itself (before the scheduler returned a job id) cannot cancel
  anything. Releases up to v0.107.0 abandoned the job on any interrupt — it ran on, on the
  allocation, with no capsule finalised.
- `--runner {local,docker,kubernetes,slurm,lsf,pbs}` — execution backend (default: `local`). Tab-completion available via `nova --install-completion`.
  - Every runner except `local` forwards **only** `NOVAFABRIC_*` environment
    variables into the workload, plus `PATH` for `slurm` and whatever you name in
    `extra_env` for `docker`/`kubernetes`/`slurm`/`lsf` (ADR-0270, ADR-0311), e.g.
    `--runner-option extra_env=LOG_LEVEL=debug`. `local` runs as you, on your
    machine, and keeps your full environment.
  - `extra_env` (and `kubernetes`'s `node_selector`) takes either
    `K=V,K2=V2` or a JSON object of strings,
    `--runner-option extra_env='{"LOG_LEVEL":"debug","HF_HOME":"/a,b"}'`; use the
    JSON form when a value contains a comma. A malformed JSON object (invalid JSON, a
    non-string value, an empty or repeated name) fails the run at setup with
    `failed_setup`, before anything is submitted. (Earlier releases silently ignored
    the JSON form, so the job ran without those variables.)
  - **The capsule is untrusted once the workload has run.** With `docker` the
    capsule directory is mounted read-write into the container. Before any
    host-side read or write, capture removes (never follows) a link, FIFO or
    other special file the workload planted at a capsule-managed path, and marks
    the capsule tampered (`metadata.capture_tampered`, `capture-health.json`
    `tampered_entries`, a `stream_tampered` proof target). Capture still exits
    with the workload's exit code and prints `✗ capture integrity: ...`;
    `nova verify` and `nova validate` fail such a capsule. See
    [Run Capsule anatomy](https://novafabric.ai/docs/architecture/run-capsule/#after-the-workload-runs-the-capsule-is-untrusted-input).
  - **Where an `extra_env` value is visible.** A value typed on the command line is in
    `nova capture`'s own argv, which every user on the host can read with `ps` for as
    long as the run lasts — including the whole time a batch job is queued and running.
    `slurm` and `lsf` hand the job script (with the `export` lines) to `sbatch` / `bsub`
    on **stdin**, never on their command line and never as a file in the capsule
    directory; the scheduler then stores it with the job, readable by you and the
    scheduler's administrators. `docker` passes each variable as `docker run -e K`
    with the value in the `docker` client's own environment, never on its command
    line (the value is still in `docker inspect`; names the docker client itself
    reads — `PATH`, `HOME`, `DOCKER_*`, proxies — stay `-e K=V`, see
    [`operator-guide.md`](https://novafabric.ai/docs/operator-guide/) §3.2); `kubernetes` writes it into the
    Job object as a literal `value:`. Treat
    `extra_env` as visible to the cluster's operators, and prefer a credential the job
    reads from a file only you can read.
  - `slurm` and `lsf` also run `sbatch` / `bsub` with a minimal environment (the
    scheduler client's own `SLURM_*`/`SBATCH_*` or `LSF_*`/`LSB_*` variables, login
    basics such as `PATH`/`HOME`/`USER`/the POSIX `LC_*` names, `NOVAFABRIC_*` and
    `extra_env`), because
    both schedulers copy the submitting process's environment into the job by
    default. **Behaviour change (v0.106.0):** a SLURM or LSF job no longer inherits
    API keys from your shell — pass them with `extra_env` (see the visibility note
    above). `extra_env` names must be shell identifiers; values are single-quoted in
    the job script, so `$`, backticks, `;` and `&` reach the job verbatim and are never
    expanded or executed by its shell. The same quoting applies to the command's own
    arguments in the `slurm`, `lsf` and `pbs` job scripts: `$VAR` in an argument is
    passed literally, as the `local` runner does.
  - **Experimental, since v0.105.0** ([ADR-0307](https://novafabric.ai/docs/decisions/)): the capsule records
    which runner ran the workload as `host.runner.name`. `docker` and `kubernetes`
    also record `host.runner.image`: the `image=` reference plus the digest the
    runtime resolved (`docker image inspect` before and after the run; the pod's
    `status.imageID`), or `unresolved_reason` when none could be resolved. The
    digest is never taken from the tag. Inside a Slurm job (any runner), or with
    `--runner slurm`, `host.slurm` records the job id, array ids, partition,
    cluster, node count and a hash of the node list, from an explicit `SLURM_*`
    allow-list. Field list:
    [run-capsule.md](https://novafabric.ai/docs/architecture/run-capsule/#hostrunner-and-hostslurm-experimental-adr-0307).
- `--runner-option KEY=VALUE` — runner-specific option, repeatable (e.g. `image=myorg/agent:latest` for `docker`, `extra_env=…` for the remote runners, `time=`/`walltime=` for the schedulers). Must contain `=` and a non-empty key, else exit 2. Keys each runner reads are listed in [operator-guide.md](https://novafabric.ai/docs/operator-guide/).
- `--environment TEXT` — **experimental** ([ADR-0126](https://novafabric.ai/docs/decisions/)). Deployment-environment tag recorded verbatim on the capsule as the additive optional `deployment_environment` field (with its provenance in `environment_source`): conventionally `production` | `staging` | `development` | `test`, or any custom string (e.g. `prod-eu`, `canary` — a value outside the conventional four warns but is accepted). Precedence: this flag > the `NOVAFABRIC_ENVIRONMENT` env var > the SDK `deployment_environment=` argument; if none is supplied both fields stay absent (read as `unknown`) and the manifest is byte-compatible with earlier capsules. Never inferred from host/branch/namespace. **Distinct from the `env.lock` technical environment** (ADR-0007) — this is a delivery-lifecycle label, not a reproducibility fingerprint. Example: `nova capture --environment production -- python agent.py`
- `--experiment TEXT`, `--variant TEXT`, `--variant-source TEXT` (+ optional `--variant-label TEXT`, `--variant-assigned-at RFC3339`) — **experimental** ([ADR-0116](https://novafabric.ai/docs/decisions/)). Record which A/B experiment and variant an **external** allocator had active for this run, as the additive optional `variant` block on the capsule manifest (`experiment_id`, `variant_id`, `assignment_source`, plus optional `variant_label`, `assigned_at`). **Record-only:** every field is copied verbatim from what you supply — NovaFabric never assigns, splits, samples, or analyzes variants (that is LaunchDarkly/Statsig/GrowthBook territory, an explicit non-goal), so `--variant-source` (the external assigner, e.g. `launchdarkly`, `statsig`, `upstream-router`) is required with the other two and is never defaulted, and `--variant-assigned-at` is never substituted with the capture time. Precedence: these flags > the `NOVAFABRIC_VARIANT*` env vars > the SDK `variant=` mapping argument, resolved atomically per source (no cross-source mixing). If nothing supplies a block it stays absent and the manifest is byte-compatible with earlier capsules. An incomplete flag set fails before capture starts; incomplete ambient env vars warn and are ignored (never block the workload). Example: `nova capture --experiment exp1 --variant arm-b --variant-source statsig -- python agent.py`
- `--session-id ULID`, `--session-sequence INT` — **experimental** ([ADR-0122](https://novafabric.ai/docs/decisions/)). Tag the run as one ordered turn of a multi-turn *session* (a conversation or workflow of N otherwise-independent runs), recorded as the additive optional `session_id` / `sequence` back-reference fields on the capsule manifest. `--session-id` must be a ULID (create one with `nova session new`); `--session-sequence` is the zero-based turn index and requires `--session-id`. Precedence: these flags > the `NOVAFABRIC_SESSION_ID` / `NOVAFABRIC_SESSION_SEQUENCE` env vars > the SDK `session_id=`/`session_sequence=` arguments, resolved atomically per source. Absent = a standalone run, byte-compatible with earlier capsules. The `session.json` manifest (`nova session`, below) stays the **authoritative** ordered index; the capsule-side fields are advisory. **Not** the parent/child distributed-run hierarchy (ADR-0039) — that groups the workers of *one* job; a session groups *separate* runs over time. Example: `nova capture --session-id 01HZ8S9K3M4YZ2K7N9DPBYK2W0 --session-sequence 2 -- python agent.py`
- `--mark-provenance` — write a C2PA synthetic-content provenance marker (`c2pa-manifest.json`, with the `c2pa.ai.generated: true` EU AI Act Art.50 disclosure) into the capsule when the run produces model output. The marker is written before NovaSeal so it is covered by the capsule signature (ADR-0074). Opt-in; non-blocking. Example: `nova capture --mark-provenance python agent.py`
- `--fast-emit` — install capture hooks **lazily** in the workload subprocess (ADR-0092 slice B). The default path imports every present SDK (`openai`, `mcp`, `requests`, …) at startup purely to patch it — measured at ~717 ms for `openai`, ~340 ms for `mcp`, paid even if the workload never calls them. `--fast-emit` patches each SDK only if/when the workload itself imports it, so unused SDKs are never imported by capture. **Measured (warm-fs, orchestrator):** a compute-only workload **2068 ms → 464 ms (−78 %)**; an `import openai` workload **2223 ms → 1509 ms (−32 %)** — the saving scales inversely with SDK usage. Fidelity is unchanged. Runs in-process (not delegated to the warm daemon). Example: `nova capture --fast-emit python agent.py`
- `--emit-spool` — **experimental** (ADR-0092 slice C). Also write run-boundary EventEnvelope v1 records (`run.start`, `capsule.finalize`) to the local event spool (`$NOVAFABRIC_SPOOL_DIR`, default `$NOVAFABRIC_HOME/spool`) so the resident `novafabric-spool-forwarder` can drain and forward them to the collector tier over NATS JetStream. Off by default; fail-open — an event the spool cannot take (for example 10 000 segments no forwarder has drained) is dropped with a logged warning (`capture.record_dropped`, stream `spool`), never evicting an undrained one; **edge-keyless** — signing happens at the hub, not here (hub-sign default). Runs in-process (not delegated to the warm daemon). Example: `nova capture --emit-spool python agent.py`
- `--emit-otel-genai` — **experimental** (NF-032, [ADR-0098](https://novafabric.ai/docs/decisions/)). After capture, emit the run outward as OTel GenAI `gen_ai.*` spans (OTLP-shaped JSON) to `<capsule>/otel-genai-spans.json`: a root `invoke_agent` span plus a `chat` client span per model call and an `execute_tool` span per tool call. Every span carries `novafabric.mapping_version` and an honest `novafabric.semconv_maturity` (`stable` on LLM client spans, `development` on agent/tool spans — OTel GenAI agent spans are Development-status). **Severity projection (experimental, ADR-0127 P4):** a `chat`/`execute_tool` span whose record carries a `log_level` also gets `novafabric.severity_number` + `novafabric.severity_text` (OTel logs `SeverityNumber` scale: `debug`→5/`DEBUG`, `info`→9/`INFO`, `warn`→13/`WARN`, `error`→17/`ERROR`; vendor-namespaced because OTel defines no span-level severity attribute). No level recorded → neither attribute (never defaulted to `INFO`). Additive; runs in-process. Example: `nova capture --emit-otel-genai python agent.py`
- `--capture-content` — **opt-in** (NF-033). With `--emit-otel-genai`, include request messages in the emitted spans, routed through the ADR-0009 secret-redaction gate and size-bounded (ADR-0021 span cap). Off by default — spans carry no message/choice content unless this is set.
- `--capture-media` — **experimental, opt-in** ([ADR-0125](https://novafabric.ai/docs/decisions/)). Store the bytes of multimodal message parts on model calls (inline base64 images/audio/documents — Anthropic `source.type: base64` blocks, OpenAI `image_url` data-URLs and `input_audio`) **content-addressed** in the capsule blob store at `outputs/<sha256>.<ext>` (deduplicated; bounded per part, default 10 MiB, `NOVAFABRIC_MEDIA_MAX_BYTES` override) and list each blob as an `Artifact` in the sealed manifest. **Off by default** (ADR-0021 §4 privacy-by-default): the part is always rewritten to a `media` reference block — IANA `media_type`, `sha256:<hex>` `content_hash` over the raw bytes, `byte_size` — and without this flag the bytes are discarded after hashing (`blob_ref: null`, reference-only). Inline base64 never lands in `model-calls.jsonl` either way; URL-referenced media is never fetched. `nova validate` re-hashes every captured blob against its recorded `content_hash` (tamper ⇒ validation fails); read back with `nova media list`. Example: `nova capture --capture-media -- python vision_agent.py`
- `--masker NAME` — **experimental** ([ADR-0135](https://novafabric.ai/docs/decisions/)). Enable a registered PII masker for this capture, by `novafabric.maskers` entry-point name or dotted import path (repeatable). Custom maskers run **after** the built-in ADR-0009 secret scanner — built-ins always run and can never be disabled by a plugin — and every mask is attributed in `redaction-proof.json` (`masker_findings[]`). Fail-closed: a crashing, hanging, or invalid masker redacts the field (recorded in `masker_errors[]`) and never blocks the workload; an unresolvable masker aborts capture *before* the workload runs. Example: `nova capture --masker novafabric-email python agent.py`
- `--masking-config PATH` — **experimental** (ADR-0135). Path to a `masking.yaml` describing the custom masking pipeline (masker order, per-masker `timeout_ms`, `max_input_bytes`, `on_error: redact|drop`, opaque `config`). Defaults to `.novafabric/masking.yaml` when that file exists. Absent config or `enabled: false` ⇒ capture behaves exactly as ADR-0009 today, byte-for-byte. Schema: `schemas/masking-config.schema.json`. See the [developer guide](https://novafabric.ai/docs/developer-guide/#writing-a-custom-pii-masker-adr-0135--experimental) for writing a masker.
- `--pii-subject ID` — **experimental** (ADR-0314). Names the data subject this run's PII belongs to. Detected PII (the cap-001 regex detector: email, phone, person name) and every literal occurrence of `ID` in the capsule's text targets are replaced by AES-256-GCM envelope tokens (`[NFPII:v1:…]`, `schemas/pii-envelope.schema.json`) under the subject's DEK in `$NOVAFABRIC_HOME/dek.db`; each one is listed in the capsule's `redaction_manifest.json`. [`nova pii erase ID`](https://novafabric.ai/docs/cli-reference/compliance/#nova-pii-erase-subject_id) then makes them permanently unreadable (readers render `[erased]`). Requires `NOVA_PII_PEPPER` (capture refuses to start without it). If the DEK cannot be created, the PII is masked (`[REDACTED:…]`) and a `masker_errors[]` entry is recorded — never stored in plaintext; the workload is never blocked. Text that is not UTF-8 (Latin-1, for example) is protected byte-for-byte, and a match written straight after CJK or accented letters is protected (releases up to v0.107.0 skipped both, leaving the PII in plaintext). Not covered: binary artifacts (with NUL bytes) and oversize ones, media blobs, in-process (adapter/decorator) capsules, and the `redaction-proof.json` whole-file `hash_before` of the ADR-0009 scanner. Without `--pii-subject` nothing is encrypted.

Use `--` to separate `nova capture` options from commands that contain flags:

```bash
nova capture -- python script.py -v --config cfg.yaml
```

The capsule is written to `<output-dir>/<ulid>/`. On exit (success or failure),
all artifacts are finalized and secret-scanned before the process returns.

Output:
```
✓ Capsule written: ~/.novafabric/capsules/01HXAY7M5JZ8R7K4P9DPBYK2WX  (run_id=01HXAY7M5JZ8R7K4P9DPBYK2WX)
```

Exit code mirrors the wrapped command's exit code, with two exceptions that
NovaFabric produces itself: `124` when the workload exceeded its wall-clock
deadline, and `127` when the workload **never started** (the command does not
exist, is not executable, or the runner could not launch it). A capsule is
written in every case, including both of those — the attempt is evidence.

Because a real program can also exit `127`, the code alone cannot tell the two
apart, so the never-started case prints an extra line naming the reason:

```
✗ Workload never started: command not found: my-agnet
✗ Capsule written: ~/.novafabric/capsules/01HXAY7M5JZ8R7K4P9DPBYK2WX  (run_id=01HXAY7M5JZ8R7K4P9DPBYK2WX)
```

The capsule says the same thing: its `error` block carries
`type: WorkloadNotStarted` and the runner's reason as `message`, instead of the
`NonZeroExit` / "Command exited with code 127" it records for a program that ran
and failed. The local runner says `command not found: <name>` only when the name
does not resolve on the workload's `PATH`; any other launch failure (for example
a script whose shebang interpreter is missing) keeps the operating system's own
wording.

**Observation log levels (ADR-0127 — experimental).** Every record in
`model-calls.jsonl` / `tool-calls.jsonl` may carry an additive optional severity
trio: `log_level` (`debug | info | warn | error`, lower-case), a secret-scanned
one-line `status_message`, and a `log_level_source` provenance
(`framework | span-status | adapter | user`). The level is a **stored forensic
attribute** — written once at capture, never acted on (no alerting, paging,
retrying, or blocking). Producers normalize framework names before writing
(`WARNING` → `warn`, `CRITICAL`/`FATAL` → `error`, `TRACE` → `debug`); an
out-of-domain value is rejected at write, and a record without the fields is
byte-identical to today — old capsules stay valid and read identically, with a
missing `log_level` read as `info` by filters (absence is preserved, never
back-filled). The OTLP trace import (server `/api/otlp/v1/traces`) maps a span
that reported `STATUS_CODE_ERROR` to `log_level: error` with
`log_level_source: span-status`, and (**experimental**, ADR-0127 P4 inbound) consumes the
OTel `SeverityNumber` carried by `novafabric.severity_number`/`novafabric.severity_text`
span attributes (as written by `--emit-otel-genai`) or by a span event's
`severityNumber`/`severityText`: 1–8 → `debug`, 9–12 → `info`, 13–16 → `warn`, 17–24 →
`error`, so a level survives an export→import round trip. The most severe of span status
and severity wins (span status keeps a tie); a severity-decided level records
`log_level_source: adapter`. Out-of-range or non-integer severity is ignored — never
guessed — and stays under `otlp.unmapped`. Filter recorded levels offline with
`nova query --where 'log_level >= warn'` (severity-ordered, ADR-0129). Python
capture API: `novafabric.capture.log_level` (`normalize_log_level`,
`resolve_log_level` — most-severe source wins, provenance recorded).

**Automatic capture hooks.** During `nova capture`, the following SDK calls are
recorded automatically when the corresponding library is importable:

| SDK | What is captured | File |
|---|---|---|
| `openai` | chat completion calls | `model-calls.jsonl` |
| `anthropic` | messages calls | `model-calls.jsonl` |
| `httpx` | requests to URLs in the URL registry (default: OpenAI, Anthropic, Cohere, Together, Mistral, Replicate) | `model-calls.jsonl` |
| `requests` | same registry — covers LangChain, LlamaIndex REST adapters, `boto3`/Bedrock, and any SDK that ships over `requests` | `model-calls.jsonl` |
| `mcp` (Model Context Protocol) | every `ClientSession.call_tool` invocation | `tool-calls.jsonl` (transport=mcp, full envelope) |
| `requests`/`httpx`/`aiohttp`/`urllib3` | every outbound HTTP request (AI or not), as a `NetworkEvent` | `network_events.jsonl` |
| third-party plugins | any class registered under the `novafabric.hooks` entry-point group | per the plugin's contract |

If a library isn't installed, the corresponding hook is silently a no-op. No
configuration needed.

The capsule also carries event streams written by the in-capture `EventRecorder`
when the corresponding events occur: `network_events.jsonl` (HTTP),
`file_events.jsonl` (file operations), and `human_approvals.jsonl` (approval
gates). The capsule manifest references each stream (`network_events_ref` etc.)
only when it is non-empty.

**Third-party plugins (experimental, v0.5.x).** Any Python package that
declares a class under the `novafabric.hooks` entry-point group is auto-discovered
at capture time. A failing plugin is isolated and logged — it cannot break the
built-in hooks. See [`docs/integrations/writing-a-hook-plugin.md`](https://novafabric.ai/docs/integrations/writing-a-hook-plugin/)
for the contract; the strategic context is RFC-0001.

**Customizing the URL registry (v0.5.x).** The wire-level hooks (`httpx`, `requests`) classify outbound URLs against a YAML registry vendored at `src/novafabric/capture/hooks/url_registry.yaml`. The registry is extended automatically at call time by `OLLAMA_BASE_URL` (langchain_ollama) and `OLLAMA_HOST` (ollama SDK) — non-default Ollama ports are captured without any manual configuration. For other private endpoints or providers, drop a replacement file at `~/.novafabric/url_registry.yaml`:

```yaml
schema_version: "0.1.0"
patterns:
  - match: "internal-llm.example.com"
    gen_ai_system: "internal-prod"
    transport: "http"
  - match: "api.openai.com"
    gen_ai_system: "openai"
    transport: "http"
```

A user-override file **replaces** the vendored default — copy the entries you still want from the default before editing. To override per-invocation, set `NOVAFABRIC_URL_REGISTRY=/abs/path/to/registry.yaml`. Per RFC-0001 §"Adoption / migration plan," merge semantics for overrides are deferred to v0.6 with a dedicated ADR.

**MCP capture (v0.5).** Each `call_tool` invocation produces a `tool-calls.jsonl`
record with `transport: "mcp"` and a complete `mcp` sub-object:

```json
{
  "transport": "mcp",
  "tool_name": "read_file",
  "mcp": {
    "server_name": "filesystem",
    "server_version": "1.0.0",
    "method": "tools/call",
    "request_id": "01KR4...",
    "envelope": {"jsonrpc": "2.0", "id": "01KR4...", "method": "tools/call",
                 "params": {"name": "read_file", "arguments": {...}}},
    "response_envelope": {"jsonrpc": "2.0", "id": "01KR4...", "result": {...}}
  },
  "status": "success",
  ...
}
```

The hook captures at the `ClientSession.call_tool` boundary (`experimental`, v0.5;
tested in `test_mcp_proxy.py`). For uninstrumented agents (Claude Desktop, Cursor,
Continue, third-party SDKs that do not import the Python `mcp` package), use
`nova mcp-proxy` below.

---

### nova session (experimental, ADR-0122)

Group N otherwise-independent runs into one multi-turn **session** — a
conversation or workflow whose turns are separate `nova capture` invocations.
A session is a local, content-addressed `session.json` manifest
(`$NOVAFABRIC_SESSION_DIR`, default `$NOVAFABRIC_HOME/sessions/<session_id>/`)
that references each member capsule by relative path + sha256 of its
`capsule.yaml`. It copies no capsule data and **never writes a member capsule**
(one capsule = one writer). Schema: `schemas/session-manifest.schema.json`.

**Not the parent/child hierarchy** (ADR-0032/0039): parent/child groups the
WORKER capsules of *one* distributed job; a session groups *N separate runs*
performed in sequence. The two compose — a session member may itself be a
distributed-run PARENT capsule.

```bash
# Create a session, capture its turns, group them
SID=$(nova session new --kind conversation)
nova capture --session-id "$SID" --session-sequence 0 -- python agent.py "hello"
nova capture --session-id "$SID" --session-sequence 1 -- python agent.py "and then?"
nova session add "$SID" "$NOVAFABRIC_HOME/capsules/<run-id-turn-0>"
nova session add "$SID" "$NOVAFABRIC_HOME/capsules/<run-id-turn-1>"

nova session list                 # all sessions: kind, member count, created
nova session reindex              # (re)build the fast SQLite session index
nova session show "$SID"          # ordered turns + aggregate stats
nova session show "$SID" --json   # machine-readable: members + stats

nova session replay "$SID"        # replay every turn in order (mocked)
nova session replay "$SID" --mode forensic --json
nova session replay "$SID" --from 1 --to 2 --turn-mode 2=forensic
nova session replay "$SID" --dry-run   # plan only: nothing executed or written

# Carry the session + its member capsules to another machine
nova session export "$SID" -o session.zip
nova session verify-bundle session.zip       # offline, exit 1 on any problem
nova session import session.zip --session-dir /elsewhere/sessions
```

Subcommands:

- `nova session new [--kind conversation|workflow|custom] [--user REF]` —
  create an empty session manifest; prints the new `session_id` (a ULID) on
  stdout, script-friendly. `--user` is an opaque, redaction-safe actor
  reference (use a hash or handle, never a raw identifier).
- `nova session add <session_id> <capsule>` — append a capsule (directory path,
  or a run_id under the default capsule directory) as the next ordered member;
  auto-assigns `sequence`, records the content-addressed `capsule_ref`, copies
  `started_at`. `--role TEXT` labels the member (e.g. `user-turn`). A finalized
  session refuses adds unless `--reopen` is passed. Adding the same run twice
  is rejected.
- `nova session list [--json] [--rebuild-index]` — enumerate sessions, newest
  first. **Experimental (ADR-0122 P3):** served from the local SQLite session
  index (`<sessions-root>/.session-index.sqlite`) when it is fresh — every
  indexed manifest's `(mtime, size, inode)` still matches disk, checked by
  `stat` without parsing any manifest or touching any capsule directory. A
  missing, stale, corrupt, or wrong-version index falls back to the
  directory scan (identical output) and, for stale/corrupt, prints a hint on
  stderr to rebuild. `--rebuild-index` rebuilds first. The index and the
  scan use the same entry filter (a symlinked session directory is skipped
  by both), and a listing opens the index read-only — it never creates it.
- `nova session reindex [--json]` — **experimental (ADR-0122 P3).**
  (Re)build the session index from the `session.json` manifests (a corrupt
  or foreign-version file is discarded and recreated). The index is a
  rebuildable cache — the manifests stay authoritative; `new`/`add`/`import`
  refresh an existing index row write-through but never create an index.
  WAL journal + busy timeout; safe to run concurrently.
- `nova session export <session_id> -o PATH [--capsule-dir PATH] [--json]` —
  **experimental (ADR-0122 P4).** Write the session and every member capsule
  as one ZIP: `session.json` byte-for-byte, `capsules/<run_id>/…`, and a
  digest index `session-bundle.json` (`artifacts[]` sha256 list +
  `manifest_hash`, the same recipe as an Evidence Bundle; per-member
  `capsule_hash` is the Evidence Bundle Merkle root). Deterministic: sorted
  entries, pinned timestamps/permissions, no wall-clock field — the same
  session gives byte-identical archives. Refuses an empty session, a
  `missing`/`tampered` member, a symlink inside a capsule (re-checked when
  each file is opened), or a non-ULID `run_id`; writes atomically (no partial file). **Unsigned** — for signed
  evidence run `nova export-evidence` on each member capsule.
- `nova session verify-bundle <bundle.zip> [--json]` — **experimental
  (ADR-0122 P4).** Offline verification: every listed digest recomputed,
  unlisted files rejected, `session.json` digest and ordering re-checked,
  each member's `capsule.yaml` matched to its `capsule_ref` and its Merkle
  root recomputed. Unsafe archive member names (`..`, absolute, backslash,
  drive letter), symlink entries, duplicates, entries expanding more than
  100x (when over 1 MiB — a zip-bomb guard), and entry-count / byte
  ceilings are refused before extraction completes; extraction counts the
  bytes actually inflated. A non-ULID `session_id` or a malformed
  `capsule_ref` is reported as a problem. Exit 1 on any problem.
- `nova session import <bundle.zip>` — **experimental (ADR-0122 P4).** Verify,
  then place the session at `<sessions-root>/<session_id>/` with its members
  under `capsules/`, where `show` and `replay` resolve them (still
  digest-gated). Nothing is written unless verification passes; the
  destination must be a direct child of the sessions root; never
  overwrites an existing session.
- `nova session show <session_id> [--json] [--capsule-dir PATH]` — the ordered
  turns with per-member integrity (`ok` / `missing` when the capsule was
  deleted or moved / `tampered` when `capsule.yaml` no longer matches the
  recorded hash — reported, never fatal, never silently repaired) plus
  aggregate stats: turns, resolved/missing/tampered counts, summed duration,
  summed `usage_totals` tokens, and summed **recorded** `nova.cost` amounts by
  currency (written at capture, never recomputed). `--capsule-dir` is an extra
  base searched as `<dir>/<run_id>` for members whose recorded path moved.
- `nova session replay <session_id> [--mode forensic|mocked|semantic|exact]
  [--on-divergence stop|continue] [--continue-past-refusal] [--json]
  [--output-dir PATH] [--capsule-dir PATH] [--from SEQ] [--to SEQ]
  [--turn-mode SEQ=MODE]... [--dry-run]` — **experimental,
  [ADR-0123](https://novafabric.ai/docs/decisions/) P1 + P5.** Replay every member
  capsule in ascending `sequence` order by invoking the **existing**
  single-capsule replay engine (the four ADR-0005 modes; default `mocked`)
  once per turn — no new replay mode, no bypass of the inherited
  mutating-tool/secret-gate defaults (ADR-0012). Each turn produces its own
  replay capsule under `--output-dir` (default `$NOVAFABRIC_HOME/replays`), and
  the session gets one `SessionReplayResult` record
  (`schemas/session-replay-result.schema.json`): ordered per-turn verdicts
  (`reproduced` / `diverged` / `refused`) plus one `whole_session_verdict`.
  Honesty rules: a `missing` or `tampered` member (same resolution as
  `session show`) is a hard per-turn **refusal**, halting the session unless
  `--continue-past-refusal` (the override is logged into the result); a soft
  divergence (the re-executed turn exited non-zero, or an `exact`-mode
  precondition failed → refusal) halts under the default
  `--on-divergence stop` and may be continued past with
  `--on-divergence continue`; turns after a halt are absent from the record,
  never marked `skipped`; a session with sequence gaps, or an empty session,
  refuses outright. Exit code is 0 only when the whole-session verdict is
  `reproduced`. **P5 (experimental):** `--from`/`--to` (inclusive; one bound
  extends to the session edge) replay one contiguous slice, recorded as the
  optional `range` field so the verdict is read as covering a slice;
  `--turn-mode SEQ=MODE` (repeatable) pins a per-turn mode (ADR-0123 D6),
  recorded in each turn's `effective_mode` and in the optional
  `turn_mode_policy` field — a pin for a turn that is absent or outside the
  slice is refused, never silently ignored; `--dry-run` prints the plan
  (turn order, per-turn effective mode, member integrity, and each turn's
  recorded tool calls classified by the inherited per-capsule policy:
  mock/allow/deny/live counts and how many are mutating) and executes and writes
  nothing (`exact`-mode preconditions are only checked on execution).
  *Still future design (planned): content-addressed state-seam verification
  between turns (P2 — so a slice's first turn replays from its captured
  inputs), the composed session attestation + `--attest` (P4), and the
  session-wide cost ceiling.*

All commands are local-first (no server, no network for
`forensic`/`mocked` replay) and read-only over member capsules.
`--session-dir PATH` on every subcommand overrides the sessions root.

### nova media (experimental, ADR-0125)

Read surface over the **content-addressed media** recorded on a capsule's
model calls ([ADR-0125](https://novafabric.ai/docs/decisions/)). When a
model call's messages carried inline media (base64 image/audio/document
blocks), capture rewrites each part to a `media` reference block — IANA
`media_type`, `sha256:<hex>` `content_hash` over the raw bytes, `byte_size`,
`redacted`, and (with `nova capture --capture-media`) a deduplicated
`blob_ref` into the capsule's `outputs/` blob store. Schema:
`schemas/media-part.schema.json`.

```bash
nova media list <capsule-dir>          # table: type, media_type, hash, bytes, blob_ref, redacted
nova media list --json <capsule-dir>   # machine-readable, one object per media part
```

Reference-only parts (the default — ADR-0021 privacy-by-default) show
`— (reference-only)` for `blob_ref`: identity is proven by hash without
holding the bytes. Integrity checking is `nova validate`'s job — it re-hashes
every captured blob against the recorded `content_hash` and fails on a
missing or tampered blob. Local-first, read-only, no server.

### nova api-proxy (v0.6.4)

Transparent HTTP proxy that sits between a non-Python LLM client and an
upstream provider, recording every request/response pair as a
`model-calls.jsonl` entry. Implements [ADR-0026](https://novafabric.ai/docs/decisions/).

Use when the client cannot import Python hooks — Claude Code, Cursor,
Continue.dev, or any Node/Go/Rust agent that uses a `*_BASE_URL` env var.

```bash
# Terminal 1 — start the proxy
nova api-proxy \
  --upstream-url https://api.openai.com \
  --listen 127.0.0.1:8765 \
  --capsule-dir .novafabric/runs/<run-id>

# Terminal 2 — point the client at it
export OPENAI_BASE_URL=http://127.0.0.1:8765
claude ...   # or cursor, or any LLM client that respects BASE_URL
```

Options:
- `--upstream-url URL` (required) — upstream LLM API base URL (e.g. `https://api.openai.com`)
- `--listen host:port` — listener address (default: `127.0.0.1:8765`)
- `--capsule-dir PATH` — active capsule directory. Without it: inside a `nova capture` child (where the runner sets `NOVAFABRIC_SPAN_ID`) the capture's capsule `$NOVAFABRIC_CAPSULE_DIR`; otherwise `$NOVAFABRIC_CAPSULE_DIR` is the capsule store root and a fresh ULID capsule is created under it; with neither, under `$PWD/.novafabric/runs/`. Same rule as `nova mcp-proxy`
- `--span-id HEX` — parent OTel span id (16 hex chars); falls back to `$NOVAFABRIC_SPAN_ID`
- `--upstream-timeout FLOAT` — timeout in seconds for each upstream connect/read, not for the whole call (default: `60.0`)

The proxy performs base-URL-override only — no TLS MITM, no local CA. Both
streaming (`text/event-stream`) and non-streaming responses are captured.

---

### nova mcp-proxy (experimental, v0.5.x)

Transparent stdio proxy that sits between an MCP client and an upstream MCP
server, recording every `tools/call` request/response pair into the active
capsule. Implements ADR-0015 §Secondary.

```bash
nova mcp-proxy -- npx -y @modelcontextprotocol/server-filesystem /tmp
```

Which capsule it records into: `--capsule-dir` if given; inside a `nova capture` child (the runner
sets `NOVAFABRIC_CAPSULE_DIR` **and** `NOVAFABRIC_SPAN_ID`) the capture's own capsule; otherwise
`NOVAFABRIC_CAPSULE_DIR` is the capsule store root, as for `nova capture`/`query`, and a fresh ULID
capsule is created under it (it was once used as the capsule itself, writing streams into the store
root); with neither, a fresh capsule under `$PWD/.novafabric/runs/`.

With an explicit capsule:

```bash
nova mcp-proxy --capsule-dir .novafabric/runs/01HX.../ -- /usr/local/bin/my-mcp-server --flag
```

**Claude Desktop integration.** Replace the upstream server's entry in
`claude_desktop_config.json` with a proxy invocation:

```json
{
  "mcpServers": {
    "filesystem": {
      "command": "nova",
      "args": [
        "mcp-proxy",
        "--capsule-dir", "/Users/me/.novafabric/runs/01HX...",
        "--",
        "npx", "-y", "@modelcontextprotocol/server-filesystem", "/tmp"
      ]
    }
  }
}
```

Records emitted by the proxy use the same `tool-calls.jsonl` schema as the
client-wrapper hook, plus `extensions["io.novafabric.capture_method"] = "proxy"`
and `extensions["io.novafabric.mcp_protocol_version"]` (sniffed from the
upstream's `initialize` response). Verbatim JSON-RPC envelopes — request and
response — are recorded; the proxy never rewrites bytes.

**Status: experimental.** Stdio transport only. HTTP/SSE transport,
`resources/read`, `prompts/get`, and `sampling/createMessage` capture are
deferred to v0.6+. Multi-upstream routing and config files are out of scope —
one proxy invocation per upstream server.

---

## Collector buffer operations (experimental, v0.51.0, ADR-0020)

### nova collector rebuild

Rebuild the downstream store by replaying the durable JetStream event buffer
from offset 0 — the SPK-COL-1-proven recovery path (byte-equal rebuild,
per-run order preserved, RF1 broker-restart safe). Requires
`pip install novafabric[scale]` (nats-py).

```bash
nova collector rebuild --target ./rebuilt
nova collector rebuild --target ./rebuilt --stream nova-evidence \
    --subject "nova.evidence.>" --report rebuild-report.json
```

Options:
- `--target DIR` — directory to materialize per-run JSONL partitions into (required)
- `--nats-url URL` — broker (default: `$NOVA_NATS_URL` or `nats://localhost:4222`)
- `--stream NAME` — JetStream stream (default: `$NOVA_NATS_STREAM` or `nova-evidence`)
- `--subject FILTER` — subject filter (default: `$NOVA_NATS_SUBJECT` or `nova.evidence.>`)
- `--report PATH` — write the `RebuildReport` JSON (per-run sha256 digests, order flags)

Exit codes: 0 — rebuilt, order preserved · 1 — broker unreachable / drain error,
or `--target` already holds `*.jsonl` partitions · 2 — rebuilt but a per-run `seq`
order violation was detected.

Events without a parseable `run_id` are routed to the `_unattributed`
partition, never dropped. A `run_id` comes from whoever published the event, so it
names a file only when it is one plain file name (`<run_id>.jsonl`); an absolute,
`..`, separator-holding or control-character `run_id` goes to
`_unsafe-<sha256 prefix>.jsonl` inside the target, with the original `run_id` kept
in each record and in the report's `partition_file`. Each partition is created
fresh (never appended, never through a link): rebuild into an empty directory, so a
file holds exactly the events its digest describes. Before v0.107.0 an absolute
`run_id` appended to any `*.jsonl` the user could write (review trust-evidence-07). See also `deploy/collector-arrow/` for the
OTel-Arrow wire profile (31.5 % measured egress reduction).

---

## Warm capture daemon (experimental, ADR-0092, Linux only)

A long-lived per-node daemon that imports `novafabric` once and serves each run
from a fork, eliminating the per-run orchestrator cold-start at fleet scale
(realizes SI-2; extends [ADR-0020](https://novafabric.ai/docs/decisions/)).
Strictly opt-in — with no daemon running, `nova capture` behaves exactly as before.

### nova daemon start | stop | status

```bash
nova daemon start                  # foreground; bind $NOVAFABRIC_HOME/run/capture.sock
nova daemon start --max-concurrency 128
nova daemon status                 # running / not running
nova daemon stop                   # SIGTERM the running daemon
```

Run `nova daemon start` under a process supervisor (systemd, a Slurm Prolog, or
a Kubernetes DaemonSet). The socket is created mode 0600 under a 0700 directory,
owned by the agent UID; connections from other UIDs are rejected
(`SO_PEERCRED`). There is no network listener.

### novacap \<cmd...\>

Stdlib-only thin client (no `novafabric` import, so ~tens of ms to start). It
forwards the command, cwd, environment and your stdin/stdout/stderr to the daemon.
As with `nova capture`, the workload's stdout and stderr are **captured, not shown**:
they are written to the capsule (`outputs/stdout.txt`, `outputs/stderr.txt`), up to
64 MiB each (the rest is counted in `runner_metadata.stdout_truncated_bytes` /
`stderr_truncated_bytes` and noted in the stream). Earlier docs said the streams
passed through to the terminal; they never did.

```bash
novacap python agent.py
```

If no daemon is reachable, or the daemon refuses the run (`busy`, `bad-op`,
`uid-denied`), `novacap` falls back to `nova capture --no-daemon` with a
one-line stderr warning — it never blocks your workload. A daemon lost *after*
accepting a run exits 1 without re-running the workload. Ctrl-C, or `novacap`
itself being killed or disconnected, cancels the run: the daemon worker passes
the signal to the workload, which gets 10 s to exit before SIGKILL, and the
worker itself is killed only after 15 s, so it is always there to stop the
workload. For fleet use,
invoke `novacap` as the per-run entry (e.g. the Slurm `srun` wrapper) — that is
where the cold-start saving is realized.

`nova capture` also gains `--daemon/--no-daemon` (default auto): a *plain*
capture delegates to the daemon when one is reachable, but any invocation using
`--runner`, `--runner-option`, `--timeout`, `--asset`, `--mark-provenance`,
`--capture-media`, or `--output-dir` runs in-process so those flags are honored.

**Scope honesty:** the daemon removes the orchestrator's own import cold-start
(measured: `/bin/true` capture 593.9 ms → 209.6 ms, −64.7 % warm-fs). A
nova-instrumented *Python* agent still pays a one-time `sitecustomize` import
inside its own process to install the wire hooks; reducing that is a later slice.
A capsule produced via the daemon is structurally identical to one from a direct
`nova capture`.

---

## Phase 3 — Distributed run commands (v0.15.0, ADR-0044/0045/0046)

Commands for parent/child capsule hierarchies (distributed Slurm/K8s runs).

### nova run new-run-id

Print a fresh ULID for use as `NOVAFABRIC_GLOBAL_RUN_ID`. Also available as top-level `nova new-run-id`.

```bash
export NOVAFABRIC_GLOBAL_RUN_ID=$(nova run new-run-id)
nova run new-run-id   # prints e.g. 01HXAY7MZPQRSTUVWXYZ
```

### nova run validate-distributed \<capsule-dir\>

Validate a distributed (parent/child) run capsule tree.

```bash
nova run validate-distributed .novafabric/runs/01HXPARENT/
nova run validate-distributed .novafabric/runs/01HXPARENT/ --parent-run-id 01HXPARENT
```

Options:
- `--parent-run-id TEXT` — override parent run_id (default: read from `capsule.json`)

Exit codes: `0` = COMPLETE, `1` = FAILED, `2` = PARTIALLY_COMPLETE, `3` = RUNNING (children still arriving; releases up to v0.107.0 reported it as `FAILED` with exit `1`).

### nova run show \<capsule-dir\>

Show a parent capsule and optionally its children in a tree view.

```bash
nova run show .novafabric/runs/01HXPARENT/
nova run show .novafabric/runs/01HXPARENT/ --with-children
nova run show .novafabric/spool/ --run-id 01HXPARENT --with-children --output json
```

Options:
- `--run-id TEXT` — parent run_id (inferred from `capsule.json` if omitted)
- `--with-children` — render the full child tree
- `--output text|json` — output format (default: `text`)

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

Query lineage edges for a distributed run.

```bash
nova run lineage 01HXPARENT
nova run lineage 01HXPARENT --edge-types contains,spawned --output json
nova run lineage 01HXPARENT --spool-dir .novafabric/spool/
```

Options:
- `--spool-dir PATH` — capsule spool directory (default: `.`)
- `--edge-types TEXT` — comma-separated filter: `contains,spawned,delegated_to,replayed_from,member_of_session,wrote_memory,read_memory`
- `--output, -o text|json` — output format (default: `text`)

---

## Memory commands

Memory provenance (ADR-0143 P1). Answers the poisoned-read question: an agent
gave a bad answer from something it remembered — where did that value come
from, and who else read it?

These commands read `memory_operations.jsonl` from a capsule. A capsule
without that file is valid; the commands report no operations rather than
failing. **No memory values are shown** — provenance is by key only, so the
graph never becomes a second copy of the content (ADR-0021 §4).

### nova memory lineage \<capsule\>

List the memory provenance edges implied by a capsule: `wrote_memory`
(run → item) on each write or update, `read_memory` (item → run) on each
read. Deletes emit no edge.

```bash
nova memory lineage .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/
nova memory lineage .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --output json
```

Options:
- `--output, -o text|json` — output format (default: `text`)

### nova memory trace \<capsule\> --key \<memory-key\>

Back-trace one memory key: which runs wrote it (oldest first), and which
runs read it (the blast radius).

```bash
nova memory trace .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --key user_prefs
nova memory trace .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ -k user_prefs -o json
```

```bash
nova memory trace runs/A/ --key user_prefs --also-capsule runs/B/ --also-capsule runs/C/
```

Options:
- `--key, -k TEXT` — memory key to trace (required)
- `--also-capsule PATH` — another capsule to search (repeatable)
- `--output, -o text|json` — output format (default: `text`)

**Scope, honestly:** a persistent memory store exists so one run can read what
another wrote, so a single capsule usually *cannot* answer this — the runs that
read a poisoned key live in their own capsules, not the writer's. Pass every
capsule that might have touched the key.

The result always reports **how many capsules were searched** and how many
carried memory operations, in both output formats. That matters: a blast radius
over 3 of 50 capsules is not the blast radius, and an answer whose coverage is
unstated reads as a complete one. Writers and readers are ordered by event time
*across* capsules, and a run appearing in two of them is counted once.

A capsule path that does not exist is an error, not a skip — silently dropping
one would shrink a blast radius without saying so.

A read may carry `origin_run_id` — what the reading agent believed it was
reading. That is recorded as a *claim* on the edge, not as the edge's source:
the answer to "who really wrote this" comes from the `wrote_memory` edges, not
from the reader's own assertion.

### nova memstore access ledger | derive | provenance (experimental, ADR-0171)

**Experimental** (ADR-0171 P2, NF-392 / NF-395 / NF-396). Governance evidence about a
long-lived, **shared, at-rest** store across runs — distinct from `nova memory`, which is the
per-run view. Reads `facets.memstore_mutation` (its `records_in_this_run`, and the `access`
block) from an **explicit list of capsules**; there is no cross-run index. Read-only: nothing
is written. Every output ends with the in-mission-boundary line: NovaFabric records evidence
about the store; it never hosts, serves, manages, or gates it.

```bash
# NF-392: who read/wrote which entry, and was it in the agent's declared scope?
nova memstore access ledger --capsule runs/A --capsule runs/B --store org-kb/support [--agent triage-agent] [--uncontained] [--json]
# NF-395: back-trace a read in run C to the store-write that seeded it, then upstream
nova memstore derive --entry bl-7 --run run_C --capsule runs/A --capsule runs/B --capsule runs/C --store org-kb/support [--namespace billing] [--ledger ledger.json] [--max-depth 8] [--max-nodes 500] [--json]
# NF-396: source → store-write → later runs for one entry
nova memstore provenance --entry pb-4471 --capsule runs/A --capsule runs/B --capsule runs/C --store org-kb/support [--namespace playbooks] [--ledger ledger.json] [--json]
```

- **`contained: false` is evidence, never enforcement.** It is computed from `allowed_scope`
  (`*`, `<namespace>`, or `<namespace>/<entry-glob>`, comma-separated; the namespace part is
  never a glob) and re-verified here, so a forged flag makes the command exit 1.
- **Binding is by content identity:** a read binds to the most recent recorded write of the
  same entry whose post-op `value_digest` equals the digest the read observed (a write provably
  after the read is excluded). A contradicting reader claim is `claim_mismatch`; a read of a
  value no supplied capsule recorded writing is `unresolved` — never invented.
- **Upstream hops** (`derive`) follow the origin run's reads made before its write:
  run-level co-occurrence, not proven causation. Cycle-safe and bounded (`--max-depth` 0–64,
  `--max-nodes` 1–10000); hitting a cap reports `truncated`.
- A capsule set that omits a run yields a partial mutation chain, reported as
  `ledger_chain_ok: false` (a warning; not repaired). `--ledger` takes the sealed sidecar
  (JSON list or `{"ledger": [...]}`) instead of re-assembling.
- **Exit codes:** `0` reported (out-of-scope rows do not fail); `1` defective evidence (broken
  access chain, forged `contained`, malformed block, broken `--ledger` chain) or, for `derive`,
  a root read that binds to no recorded write; `2` nothing could be checked (unreadable/oversize
  capsule or ledger, no read/write of the entry to trace).

The other ADR-0171 surfaces (`nova memstore mutation show|verify`, `retention verify`,
`poisoning list`, `stale`, `conflicts`, `purpose`, `snapshot log`, `nova lineage memstore`) are
**planned**, not shipped.

---

## Framework Adapters (v0.26.0)

Drop-in capture adapters for four additional AI frameworks. Each adapter uses the
SDK's own native extensibility interface (ADR-0078) rather than wrapping the executor.
All framework packages are optional extras.

**Capsule finalization (since v0.105.0).** Every adapter below, and the
`@agent` decorator, finalizes its capsule through the same code as `nova capture`
(`capture/finalize.py`): secret scan, manifest redaction, ADR-0009 residual pass,
`lineage.jsonl`, ADR-0251 `evidence_digests`, the manifest gate, and a NovaSeal
seal when a signing profile exists (opt-in, ADR-0301) — so `nova verify <capsule>`
works on an adapter capsule. `--masker` maskers are a `nova capture` option and do
not run in-process. Finalization never fails the framework call: on a failure, a
gate refusal or a failed seal the capsule is left unsealed and
`metadata.finalization_error` records why.

### Where adapter capsules land, and how to refer to them

Every adapter writes to the `data_dir` it is given. With none it writes to
`$NOVAFABRIC_HOME/runs/<run-id>/` when `NOVAFABRIC_HOME` is set, otherwise to
`./.novafabric/runs/<run-id>/` under the working directory — the documented
SDK/adapter default, which is **not** the `nova capture` store
(`$NOVAFABRIC_CAPSULE_DIR`, default `~/.novafabric/capsules/`).

```bash
# Always works: the capsule path
nova replay .novafabric/runs/01HXAY7M5JZ8R7K4P9DPBYK2WX/ --mode forensic

# Since v0.105.0: the bare run id works too
nova replay 01HXAY7M5JZ8R7K4P9DPBYK2WX --mode forensic
nova diff 01HXAY7M5JZ8R7K4P9DPBYK2WX 01HXB2Q9W3N4K5M6P7R8S9T0VW
nova validate 01HXAY7M5JZ8R7K4P9DPBYK2WX
```

A bare run id is looked up in at most three directories, in order: the capture store,
`$NOVAFABRIC_HOME/runs/`, `./.novafabric/runs/` (de-duplicated; never a filesystem
search). A hit outside the capture store prints `note: run <id> found in <dir> …` on
stderr, so `--output-format json` stdout stays clean. An id present in more than one of
them is an error listing every path — pass the capsule path to choose. A command's own
`--capsule-dir` option, where it has one, restricts the lookup to that directory.
v0.104.0 and earlier resolve a bare id in the capture store only, so there use the path.

### OpenAI Agents SDK adapter (E-5)

```python
# Install: pip install 'novafabric[openai-agents]'
from novafabric.adapters.openai_agents import register

# Call once at startup before any agent runs
register()

# All subsequent Runner.run() calls are captured as nova capsules
result = await Runner.run(agent, "hello")
```

The adapter registers a `NovaCapsuleTracingProcessor` via `add_trace_processor()`.
Each trace produces one capsule in the adapter default directory (`$NOVAFABRIC_HOME/runs/`, or `./.novafabric/runs/` when `NOVAFABRIC_HOME` is unset). `capture_mode` is
`sdk-decorator` and `command` is a `@openai-agents:<workflow>` label (the trace's `RunConfig.workflow_name`), so `nova replay --mode mocked` refuses the capsule (`CapsuleNotReplayable`).
The capsule's `status` follows the SDK's own span errors. An error on an **agent** span — where the SDK records
`Max turns exceeded`, `Guardrail tripwire triggered` and an exception escaping the agent — makes it `failure` with
`exit_code: 1` and `error: {type: AgentRunError, message}` (the SDK's span message, never its `data`). An error on any
other span, such as a tool error fed back to the model, leaves the run `success` and is counted in
`metadata.span_errors` by span type.

Top-level alias: `from novafabric.adapters import register_openai_agents`

#### Agents SDK tool seam — record and serve function-tool calls (experimental)

**Status: experimental** (ADR-0306 slice 3; since v0.106.0). `register()`
above records traces but its capsules cannot be replayed. A separate helper,
`wrap_tools`, makes function-tool calls replayable offline. It does nothing on its own:
run the script under `nova capture python …`, then replay the capsule with `nova replay`
(mocked).

```python
from agents import Agent, function_tool
from novafabric.adapters.openai_agents import wrap_tools

@function_tool
def lookup_order(order_id: str) -> dict: ...

agent = Agent(
    name="support",
    tools=wrap_tools([lookup_order], {"lookup_order": "read-only"}),
)
```

```bash
nova capture -- python agent.py      # NOVA_CAPTURE_LEVEL=forensic to keep payloads
nova replay <run-id>                 # tool bodies do not run; results come from the capsule
```

- **No documented SDK hook.** Unlike ADK, the Agents SDK offers no way to skip a tool.
  `wrap_tools` returns a *copy* of each `FunctionTool` whose `on_invoke_tool` consults
  NovaFabric first — an **undocumented seam**, verified against `openai-agents` 0.17.x
  for `Runner.run`, `Runner.run_streamed`, parallel tool calls, `Agent.clone` and
  `Agent.as_tool`; `needs_approval` still interrupts a run before it. A different SDK
  release may break it, and only tools passed through `wrap_tools` are covered. Hosted
  tools and MCP servers pass through unchanged.
- **Under `nova capture`** each call writes one `tool-calls.jsonl` record
  (`transport: python`, `io.novafabric.tool_surface: openai.agents.tool`, the model's
  `io.novafabric.openai_agents_call_id`). Arguments and the result are kept only at the
  `forensic`/`air_gapped` capture level; otherwise only after-redaction digests are kept
  and replay refuses the call with a re-capture hint. The SDK turns a tool exception into a
  model-visible error string, and that string is what is recorded.
- **Under a mocked `nova replay`** the recorded result is returned and the tool body never
  runs. An unmatched call, or one whose record is not servable (made nested model/tool
  calls, including through `Agent.as_tool`; non-JSON result), is refused before the tool
  runs and the replay fails (`tool_call_unmatched` / `tool_result_not_servable`) even if
  the workload catches the error, which the SDK re-raises as `UserError`. `--permissive`
  runs an unmatched call live only when an `--allow-*` flag permits the class declared in
  `wrap_tools` (default `unknown`), and `replay.yaml` `tool_overrides` hold as on the other
  tool surfaces.
- **Outside capture and replay** a wrapped tool behaves like the original.
- A function declared with `novafabric.capture.record.tool` is already a boundary of its
  own, so the seam steps aside for it.
- **Only `nova capture python …` capsules can be replayed**, as for ADK (ADR-0306 open
  question 7). The other framework seams (LangChain/LangGraph, Pydantic AI, LlamaIndex,
  CrewAI) are **planned**.

### Google ADK adapter (E-6)

```python
# Install: pip install 'novafabric[google-adk]'
from novafabric.adapters.google_adk import make_plugin
from google.adk.runners import Runner

runner = Runner(
    agent=my_agent,
    session_service=svc,
    plugins=[make_plugin()],
)
```

The adapter implements `before_run_callback` and `after_run_callback` on a
`NovaAdkPlugin` instance. `capture_mode` is `sdk-decorator` and `command` is an `@google-adk:…` label, so `nova replay --mode mocked` refuses the capsule (`CapsuleNotReplayable`).

Top-level alias: `from novafabric.adapters import make_google_adk_plugin`

#### ADK tool plugin — record and serve ADK tool calls (experimental)

**Status: experimental** (ADR-0306 slice 3; since v0.106.0). A second,
separate plugin makes ADK tool calls replayable offline. It does nothing on its own:
run the script under `nova capture python …`, then replay the capsule with
`nova replay` (mocked).

```python
from google.adk.runners import Runner
from novafabric.adapters.google_adk import make_tool_plugin

runner = Runner(
    agent=my_agent,
    session_service=svc,
    # FIRST in the list: ADK stops at the first plugin that answers a callback.
    plugins=[make_tool_plugin({"lookup_order": "read-only"})],
)
```

```bash
nova capture -- python agent.py      # NOVA_CAPTURE_LEVEL=forensic to keep payloads
nova replay <run-id>                 # ADK tool bodies do not run; results come from the capsule
```

- **Under `nova capture`** each ADK tool call writes one `tool-calls.jsonl` record
  (`transport: python`, `io.novafabric.tool_surface: google.adk.tool`, the model's
  `io.novafabric.adk_function_call_id`). Arguments and the result are kept only at the
  `forensic`/`air_gapped` capture level; otherwise only after-redaction digests are kept
  and replay refuses the call with a re-capture hint.
- **Under a mocked `nova replay`** the plugin's `before_tool_callback` returns the
  recorded result — the way ADK documents to skip a tool — so the tool body never runs.
  An unmatched call, or one whose record is not servable (the tool raised, changed
  `tool_context.actions`, is long-running, or made nested model/tool calls), is refused
  before the tool runs; the replay fails (`tool_call_unmatched` /
  `tool_result_not_servable`) even if the workload catches the error, which ADK wraps in
  `RuntimeError`. `--permissive` runs an unmatched call live only when an `--allow-*`
  flag permits the class declared in `make_tool_plugin` (default `unknown`), and
  `replay.yaml` `tool_overrides` hold as on the other tool surfaces.
- **Outside capture and replay** every callback returns `None`.
- The plugin steps aside for ADK `McpTool`s (the MCP surface already serves them) and
  for functions declared with `novafabric.capture.record.tool`.
- **Only `nova capture python …` capsules can be replayed.** A capsule written by
  `make_plugin()` is still refused by mocked replay (`CapsuleNotReplayable`): adapters
  record a pseudo-command, not a re-runnable one (ADR-0306 open question 7). Use one
  plugin or the other per run, not both: under `nova capture`, `make_plugin()` files
  the run into its own adapter capsule.

### AWS Bedrock AgentCore adapter (E-7)

```python
# Install: pip install 'novafabric[bedrock-agentcore]'
import boto3
from novafabric.adapters.bedrock_agentcore import wrap_client

client = wrap_client(
    boto3.client("bedrock-agent-runtime", region_name="us-east-1")
)
response = client.invoke_agent(
    agentId="my-agent", agentAliasId="TSTALIASID",
    sessionId="session-1", inputText="hello"
)
for event in response["completion"]:
    if "chunk" in event:
        print(event["chunk"]["bytes"].decode())
```

The adapter wraps `invoke_agent()` and passes the `completion` EventStream through unchanged.
Each trace part it carries (with `enableTrace=True`) becomes one record in
`bedrock-traces.jsonl`, one per `Trace` kind present (orchestration, pre-/post-processing,
routing classifier, custom orchestration, guardrail, failure). A record holds the agent
identifiers and event time plus the trace body at the `forensic` capture level, or only its
`sha256` digest otherwise: an orchestration trace contains the full model prompt. The
manifest points at the file (`extensions."com.amazonaws.bedrock".traces_ref`) only when
one was written, and it never copies `inputText`. The capsule closes when the stream ends:
`success` when exhausted, `failure` when it raises (e.g. throttling; the exception still
reaches you) or when `invoke_agent` itself fails, and `partial` (`metadata.partial_reason:
abandoned`) when you stop reading, close it, or drop it unread.
`capture_mode` is `sdk-decorator` and `command` is an `@bedrock-agentcore:…` label, so `nova replay --mode mocked` refuses the capsule (`CapsuleNotReplayable`).

All non-`invoke_agent` methods are delegated transparently to the underlying client
(`__getattr__` passthrough).

Top-level alias: `from novafabric.adapters import wrap_bedrock_agentcore`

### A2A SDK adapter (E-8)

```python
# Install: pip install 'novafabric[a2a]'
from novafabric.adapters.a2a import make_interceptor
from a2a.client import A2AClient

client = A2AClient(
    base_url="http://my-agent:8080",
    interceptors=[make_interceptor()],
)
result = await client.send_message(agent_card=card, message=msg)
```

The adapter implements `before()` and `after()` on a `NovaA2AInterceptor` instance.
Only `send_message` and `send_message_streaming` calls are captured; other methods
pass through unchanged. `capture_mode` is `sdk-decorator` and `command` is an `@a2a:…` label, so `nova replay --mode mocked` refuses the capsule (`CapsuleNotReplayable`). Task envelopes are written
to `a2a-tasks.jsonl` inside the capsule.

This implements RFC-0002 §Q4 (full A2A protocol-aware capture), deferred until A2A SDK
reached 1.0 stability.

Top-level alias: `from novafabric.adapters import make_a2a_interceptor`

**Reference:** `src/novafabric/adapters/`, `design/adr/0078-ecosystem-adapters.md` (private).
