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

# Resident server

> Operate the stable nika serve firer on a container, VM or bare server.

> [!NOTE]
>
> These pages describe the published `@supernovae-st/nika@0.124.4`
> [SDK release](https://github.com/supernovae-st/nika-client/tree/v0.124.4) and its matching
> [bundled engine](https://github.com/supernovae-st/nika/releases/tag/v0.124.4). A newer engine
> release or SDK main commit does not change an installed package. Use Node.js
> 22 or newer, on macOS (arm64, x64) or Linux with glibc (x64, arm64); no
> global Nika installation is required for local mode. Versioned transcripts,
> recordings and measurements keep the release they were captured on;
> selecting this package release does not re-run those examples.

> [!NOTE]
>
> **Live project control plane.** The released engine
> discovers `nika.yaml` from the working directory toward its
> ancestors. The file is optional when built-in defaults are enough. Its
> project-shape grammar is closed: `nika` ·
> `ceiling` · `arm` · `traces` ·
> `registry`. Direct runs and the cadence path
> (`nika arm` · `nika serve`) read the same file.

`nika serve` with no `--bind` is the released resident firer. It reads the
`arm:` registry from `nika.yaml`, waits on the wall clock and ends each due
beat at the same firing law as `nika arm fire`. That default process is not
HTTP.

`--bind` + `--workflows` + `--token-file` on the **same verb** opens
authenticated HTTP. The released OpenAPI includes jobs, job SSE, cancellation,
trace verification, the download of a settled job's artifacts, workflow
discovery and schedule read/write. It has no job-list or `POST /v1/run` route.
`--once` and `--dry` cannot bind a listener.

> [!WARNING]
>
> Bare `nika serve` is the ARM firer, not HTTP. The HTTP door is opt-in
> (`--bind`). Name the live route contract and its absent routes explicitly.

## Rehearse each operating mode

```sh theme={"system"}
nika arm                 # list the beats and their next slots
nika serve --dry --once  # print what would fire now, run nothing, exit
nika serve --once        # fire what is due once, then exit
nika serve               # stay resident and wait for the next slot
```

| Mode | Behavior |
| - | - |
| `--dry` | Runs nothing; prints `would fire <label> · slot …` for each beat due now. Without `--once` it stays resident |
| `--once` | Performs one due sweep, then exits |
| no mode | Stays resident and waits for the next slot |

`--dry` is intentionally narrower than a real fire. It does not take the beat
lock or apply the complete missed-run, overlap, cost and execution policy. Use
`nika arm` to see upcoming slots.

## Reload without losing the last good registry

HOT RELOAD · INVALID EDITS DO NOT REPLACE VALID POLICY

<pre tabIndex="0">
  nika.yaml changes
  &#x20;        │
  &#x20;        ├── parses + validates ── replace registry
  &#x20;        │
  &#x20;        └── refuses ───────────── report error
  &#x20;                                    └── keep last good registry
</pre>

The server retries a refused edit on a later tick. This keeps a typo visible
without silently replacing valid policy with an empty schedule.

## Read process and beat outcomes separately

Each beat prints one decision line and appends project state. A completed
`--once` sweep exits clean even when an individual workflow failed or paused,
so supervision must read the beat lines and ledgers, not only the outer process
exit.

```text theme={"system"}
resident process
├── stdout line per beat
├── .nika/arm/<label>/history.ndjson
└── .nika/traces/<run>.ndjson
```

## Delivery and shutdown

Ctrl-C and SIGTERM stop the resident loop at its signal boundaries. The ledger
uses durable claims and receipts, which yields at-least-once delivery:

```text theme={"system"}
claim appended ── workflow starts ── receipt appended
       │                  │
       └── crash here ────┴── visible unmatched claim
```

Exactly-once is never promised. Make the workflow's external effects
idempotent when replay would otherwise duplicate harm.

## Opt-in HTTP

```sh theme={"system"}
umask 077
# owner-only bearer file · bytes never enter argv
nika serve --bind 127.0.0.1:18765 \
  --workflows ./workflows \
  --token-file .nika/serve.token
```

The listen line (measured on 0.123.0) starts with
`nika serve · listening http://127.0.0.1:18765 · GET /health` and goes on to
list the authenticated routes.

`--workflows <dir>` scopes the served registry (0.118): the listing, the
metadata route and the schedules see only the workflows under that directory,
named from the project root (`flows/quick.nika`, never `quick`); a
schedule naming a workflow outside it is refused with the teaching. Executed
HTTP workflows use the runtime journal under the project's `.nika/traces/`.
The runtime writes and seals the evidence; `nika trace verify` checks what
was written. A refusal before execution can have no journal, and missing or
incomplete evidence is distinct from a failed run. The artifact routes serve
only from a sealed journal: give the resident a run key as files first
([Server runbook](https://docs.nika.sh/sdk/operations/server-runbook.md#give-the-server-a-run-key)).
A cancellation request is an action: the runtime's eventual settlement, not
the HTTP request alone, determines the result.

`POST /v1/jobs` and `POST /v1/check` take two forms (0.118):
`{"workflow": "<name>"}` for a workflow the served registry lists — the
resident captures the world itself, exactly as a schedule fires — and the
execution snapshot `nika check <file> --json --sdk-snapshot` prints, whose
digests are optional caller-supplied integrity digests (absent, the resident
computes them; present, they must match the bytes). A retry with the same
`Idempotency-Key` finds its job before the registry is read again. The
terminal event (`execution.settled` · `execution.cancelled`) carries the
run's `settlement` whole (`status` · `cause` · `elapsed_ms` · `tasks` ·
`spend` · `error`), the same object `run_settled` flattens; `nika doctor`
says which resident runs (the stores' writer stamp beside the server lease);
`nika explain <code>` teaches every resident code.
The route table lives at `GET /v1/openapi.json`. Full matrix:
[server surfaces](https://docs.nika.sh/sdk/operations/server-surfaces.md).

## Deployment checklist

* Set a stable project `cwd` containing `nika.yaml`.
* Install an explicit `nika` binary path.
* Protect provider keys outside project source.
* Persist `.nika/traces/` and `.nika/arm/` according to policy.
* Capture stdout decision lines.
* Send SIGTERM and allow the active firing boundary to settle.

## Continue

> [card] [Arm registry](https://docs.nika.sh/sdk/project/arm-registry.md)
>
> The schedule and policy this process consumes.

> [card] [OS schedulers](https://docs.nika.sh/sdk/operations/os-schedulers.md)
>
> Let launchd or systemd own wakeups instead.

> [card] [Runtime state](https://docs.nika.sh/sdk/project/runtime-state.md)
>
> Persist the evidence behind each decision line.

> [card] [Production runbook](https://docs.nika.sh/sdk/operations/server-runbook.md)
>
> Boot, supervise, probe and investigate the process.

> [card] [Deployment topologies](https://docs.nika.sh/sdk/operations/deployment-topologies.md)
>
> Choose the right process boundary.


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