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

# Machine surfaces

> The versioned JSON wires — every human surface has a machine twin, envelopes are versioned and additive-only, exit codes are a contract.

> The law: **every human-facing surface has a `--json` twin**, every
> machine payload carries a **version envelope**, and evolution is
> **additive-only** — a field is added, never renamed or removed within
> a version. Agents and tooling parse the JSON; the pretty output is
> free to improve without breaking anyone.

## The wires

| Surface | Envelope | What it carries |
| - | - | - |
| `nika check <file> --json` | `report_version` (`1`) | the full audit report: `clean` and the `verdicts` layers (`valid` · `access_ready` · `capacity_fit` · `run_ready` · `blockers`, plus `network_tasks`, every task whose own effects can still reach the network), conformance findings (each with `code` · `severity` · `docs_url` · span), the access plan, cost intervals per task, the derivation certificate, requirements (models · secrets · inputs), secret-flow and order-law findings, hints, `risk_grade`, pricing provenance (`pricing.snapshot`) |
| `nika run <file> --dry-run --json` | `plan_version` (`1`) | the plan only, zero effects: waves, tasks, access, cost, permits, requirements. A task the run's seat would refuse prints one `error` object (`code`, `message`) instead, with exit 2 |
| `nika run <file> --json` | NDJSON stream | the live event stream, one JSON object per line, the same events the trace records. The last line is `run_settled`: `status` (`succeeded` · `failed` · `paused` · `cancelled`), `cause`, `outputs`, the `tasks` tally, `spend` with its qualifier, the `receipt` (trace path, chain head, `sealed`), `evidence` (`sealed` · `unsealed` · `lost` · `none`: what the run left behind, said rather than implied), the `access_plan` that served, and the `error` of a failed run |
| `nika explain <file> --json` | `explain_version` (`1`) | the narration of a workflow file as data: waves, cost before a token is spent, what it touches |
| `nika doctor --json` | none (stable shape) | the environment diagnosis: findings with the exact fix command, access paths, local model probes, key presence (never values) |
| `nika welcome --json` | `welcome_version` (`1`) | the mirror: what this binary contains and what this machine has, presence only |
| `nika welcome --deep --json` | `context_version` (`1`) | the whole workspace in one call: every workflow with its verdict, recent runs from the trace store, the environment, roll-ups; caps are always reported and paths stay relative |
| `nika catalog --json` | `catalog_version` (`1`) | the provider and model vocabulary: models, capabilities, key env-var names, `resolves` (whether this build drives the provider) |
| `nika catalog --tools --json` | `tools_version` (`1`) | the builtin tool catalog with model-facing JSON Schemas per tool |
| `nika inspect <file> --format json` | `graph_format` (`3`) | the one graph projection: nodes (id · `kind`: `task` · `finally` · verb · model/tool · when · fan-out · permits · cost interval) and **typed edges** (`kind`: `value` · `terminal-observation` · `failure-observation` · `control` with its `predicate` · `recovery` · `finally` with `predicate: unwind`; `binding` on data edges). Mermaid, dot and ascii derive from it. Formats 1 and 2 are retired: a reader refuses a format it does not speak; within format 3, evolution is additive-only |
| `nika compile … --json` | `compile_version` (`1`) | the compile result: its status (`ready` · `incomplete` …), the candidate, its provenance and any questions |
| `nika arm --json` | `schedule_readiness_version` (`2`) | each beat's readiness (`READY` · `UNREADY` · `DORMANT`), blockers, inputs and next fire ([arm](https://docs.nika.sh/reference/arm.md)) |
| `nika trace ls --json` | `ls_version` (`1`) | the trace store: every recorded trace with its `state` (`succeeded` · `failed` · `paused` · `cancelled` · `running` · `dead`), its writer's `liveness`, age, size, workflow and the resume marker |
| `nika trace outputs --json` | `outputs_version` (`2`) | one run's settlement and its tasks: per task `status` · `error_code` · `recovered_from` · `integrity_source` · a fan-out's `items` rows |
| `nika trace verify --json` | `verify_version` (`1`) | the verdict of the chain and the proof ladder (OK · SEALED · ANCHORED · REPLAYED) |
| `nika trace cost --json` | `cost_inspect_version` (`1`) | this project's unknown cost exposures, as data |
| `nika trace export` | OTLP | a recorded journal projected to OpenTelemetry spans with GenAI attributes (Jaeger, Grafana, Langfuse) |
| `nika spec --canon` | `schema_version` | the embedded canon (counts and names: cite it, never a remembered number) |
| `nika spec --schema` | JSON Schema `$id` | the embedded workflow schema, the same one editors validate against |
| `nika spec --schema --project` | JSON Schema `$id` | the project file's schema (`nika.yaml` · `ceiling` · `traces` · `arm:` beats), emitted from the parser and proven against its closed key sets |

`nika check -` reads the workflow from **stdin** — editors and agents
audit keystroke-fresh buffers without touching the disk.

> [!TIP]
>
> Prefer typed TypeScript over process glue? The published
> [`Nika` client](https://docs.nika.sh/sdk/local/client) (`@supernovae-st/nika@0.124.4`)
> owns binary discovery, JSON decoding, cancellation, `run.events()`
> and typed errors. `run()` returns an admitted handle; `run.result()`
> settles. `traceVerify` reads existing evidence — it does not seal,
> rerun, or prove the job was correct. The
> [SDK runtime guide](https://docs.nika.sh/sdk/runtime/events.md) maps these wires to code.

## Canonical sources

The public documentation explains the contract. Machine consumers read the
versioned CLI output or the owning repository, rather than a marketing build.

| Surface | Owner and access |
| - | - |
| Workflow schema | `nika spec --schema` or [spec schema](https://github.com/supernovae-st/nika-spec/blob/main/schemas/workflow.schema.json) |
| Diagnostics | `nika explain` or [diagnostic registry](https://github.com/supernovae-st/nika-spec/blob/main/canon/diagnostics/registry.yaml) |
| Tools and models | `nika catalog --tools --json` and `nika catalog --json` |
| Documentation for agents | [Documentation index](https://docs.nika.sh/llms.txt) |
| Shared artifacts | [Registry index](https://raw.githubusercontent.com/supernovae-st/nika-registry/main/index.json) |

For a reproducible integration, replace `main` with a reviewed commit and record
its content digest. The [knowledge system](https://docs.nika.sh/reference/knowledge-system.md) explains
how to read source revisions and distinguish a contract from a released implementation. Historical schema identifiers are stable
identities; retiring a website does not rename a language namespace.

## The exit-code contract

Scripts and agents branch on exit codes, so they are the engine CLI
exit-code contract (locked · additive-only), not an accident:

| Code | Meaning |
| - | - |
| `0` | success: a clean check, a settled run |
| `1` | the workflow ran and failed: a task settled failed, or a budget stop (`NIKA-1704`) |
| `2` | the file: check findings, a grammar refusal, a mistyped flag, a cost floor above `--max-cost-usd` (`NIKA-1709`) |
| `3` | the environment: a missing or unreadable file, no ready access path (`NIKA-1800`), an unsatisfied `--access` pin, a missing required input (`NIKA-1708`), no golden to compare |
| `4` | paused — the run parked on a blocking `nika:prompt` (durable pause · ADR-099) · not a failure but non-zero on purpose · resume with `nika run --resume <trace> --answer <task>=<value>` |
| `130` | the runtime settled as cancelled after an operator request (0.118) — completed in-flight work is counted and unstarted tasks are cancelled; read the reported evidence state to determine whether a trace was sealed · a second Ctrl-C aborts mid-flight and can leave the trace incomplete · 128 + SIGINT, the code every shell already reads as interrupted |

Stream discipline: product output goes to **stdout**, only
environmental noise goes to stderr — and in `--json` modes, progress
moves to stderr so stdout stays parseable.

## The MCP oracle

`nika mcp` serves the same truths over the Model Context Protocol, read-only,
over stdio by default or Streamable HTTP with `--transport http`: validate
(`nika_check`: a dirty workflow returns `isError: true`, mirroring the CLI's
exit 2) and learn (`nika_schema` · `nika_examples` · `nika_template` ·
`nika_canon` · `nika_catalog` · `nika_tools` · `nika_explain` ·
`nika_inspect`). The same builders produce the CLI payloads, so the two
cannot drift apart. [MCP server](https://docs.nika.sh/reference/mcp-server.md) describes each tool.

## The evolution rules

* **Versioned**: breaking a payload shape means bumping its envelope
  field — consumers pin on it.
* **Additive-only within a version**: new fields appear, existing ones
  keep their meaning.
* **Deterministic**: stable key ordering, no timestamps injected into
  otherwise-stable payloads — machine output is cache- and
  diff-friendly.
* **Presence, never values**: no secret VALUE crosses any wire, human
  or machine. Requirements name the env var; doctor reports set/unset.

> [!NOTE]
>
> Every row above was read from `nika {STATUS.version}`. An envelope you do
> not recognize is a newer payload: refuse it rather than guess.


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