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

# Arming a project

> Declare beats in nika.yaml and let the machine fire them: the readiness report, the one firer, the OS bridge and the resident firer.

> [!NOTE]
>
> **The file proposes, the machine disposes.** Arming a project means
> declaring *beats* in `nika.yaml`, what runs, when and under which
> policies, and letting the machinery fire them: an OS unit (`launchd` ·
> `systemd`), or the resident `nika serve` where no OS scheduler exists.
> Reading this page schedules nothing; firing is always a machine act.

**1. Declare the beat**

Add an entry under `arm:` in `nika.yaml`: the workflow, its cadence with
its time zone, a spend ceiling and a missed-run policy.

**2. Read the report**

`nika arm` checks every beat and prints `READY`, `UNREADY` or `DORMANT`
with the next three slots. It schedules nothing.

**3. Hand it to the machine**

`nika arm --emit launchd --write` (or `systemd`) installs the OS unit,
or `nika serve` fires the beats from a resident process.

## The `arm:` block

Each entry under `arm:` in `nika.yaml` is one beat:

```yaml theme={"system"}
nika: my-project
ceiling: 0.50            # the run default when a beat says nothing; a beat always says its own

arm:
  - workflow: workflows/nightly-report.nika
    cadence: "TZ=Australia/Sydney 45 22 * * *"
    plafond: 0.20
    manqué: rattraper-une-fois
    chevauchement: sauter
    après_saut: prochain-créneau
    inputs:
      topic: "the night"
  - workflow: workflows/on-event.nika
    cadence: on-webhook
    plafond: 0.05
    manqué: sauter
```

| Key | Required | What it means |
| - | - | - |
| `workflow` | yes | The workflow to fire: a `*.nika` path relative to the project root |
| `cadence` | yes | The IANA zone first, then five cron fields (`"TZ=Europe/Paris 30 7 * * *"`), a French weekday and time (`"TZ=Europe/Paris lundi 9h07"`) or an anchored interval (`"TZ=Europe/Paris every 2 weeks from 2026-10-05 09:00"`); or `on-webhook`, the one form without a zone. The zone resolves against the embedded tzdb, never the host's, and a scheduled cadence without one is refused (`cadence.tz-missing`) |
| `plafond` | yes | The spend ceiling of each fire in USD (`--max-cost-usd`), above zero. It has no default: choosing for the operator would be choosing who pays. Under it, paid images and speech are billed from a dated price table, and a call the table cannot price (OpenAI's default voice `gpt-4o-mini-tts`, `gpt-image-1.5`, `gpt-image-1-mini`, an unlisted model id) makes the beat `UNREADY` ([paid media](https://docs.nika.sh/guides/cost-honesty.md#paid-media-priced-refused-or-unpriced)) |
| `manqué` | yes | What a missed slot becomes when the firer comes back (table below). No default either |
| `chevauchement` | no | A new slot while the previous fire still runs: `sauter` (skip it, the default) or `file` (queue it). `remplacer` is accepted by the registry and refused by the 0.124.3 firer |
| `après_saut` | no | When the beat resumes after a skipped slot: `prochain-créneau` (the default). `à-complétion` is accepted by the registry and refused by the 0.124.3 firer |
| `où` | no | `local` (the default) or `cloud`. A `cloud` beat stays in the registry and every fire on this machine skips it |
| `actif` + `raison` + `jusqu_au` | together | The suspension triple: `actif: false` needs the reason and an ISO date. The beat sleeps until that date, then fires again. **Deleting the line does not disarm**; the triple does |
| `inputs` | no | The `--var KEY=VALUE` pairs every fire binds, one scalar per key, coerced by the workflow's declared types. A key the workflow does not declare makes the beat `UNREADY` (`input_refused`) |
| `tolérance` | no | An (m,k)-firm skip tolerance (`3/4`). The report shows it; the firer does not enforce it |
| `décalage` | no | `hash`, a deterministic offset derived from the workflow path. Accepted by the registry and refused by the 0.124.3 firer |
| `par` | no | Who armed the beat, verbatim. It proves nothing by itself: the machine's key is what authorizes, and a merge arms nothing |

The set is closed: any other key, such as `signature:` or `budget:`, is
refused (`project.unknown-key`) and `nika arm` exits `2`.

A beat that uses a refused policy is reported `UNREADY` with the reason, and
`nika arm fire`, the OS units that call it and a `nika serve --once` sweep
refuse to fire it. The two catch-up policies, `rattraper` and
`{ rattraper: N }`, are the exception the refusal names (« `nika serve`
keeps it »): the resident `nika serve` fires such a beat. Otherwise change the
policy, or suspend the beat with the triple.

### The miss policies (`manqué:`)

| Value | What a silence does | In 0.124.3 |
| - | - | - |
| `rattraper-une-fois` | Fire one catch-up run that answers for the whole silence | fires |
| `sauter` | Never catch up: a skip is an event, never an execution | fires |
| `rattraper` | Fire the latest missed slot once | refused by `nika arm fire`; the resident `nika serve` keeps it |
| `{ rattraper: N }` | Fire up to the N latest missed slots, one run each, oldest first | refused by `nika arm fire`; the resident `nika serve` keeps it |

## `nika arm`: the report

Bare, the verb reads the registry, checks each beat and its workflow, and
reports what is ready, what fired and what fires next. It schedules nothing:

```text theme={"system"}
$ nika arm
4 beats in /home/alice/project/nika.yaml

  [READY] workflows/nightly-report.nika · TZ=Australia/Sydney 45 22 * * *
         · ready in the current configuration; OS activation not verified · authority not acquired
         ✓ PROUVÉ (génération + créneau · ni projet ni hôte) · fired · 2026-10-25T11:45:20.747596Z · slot 2026-10-25T11:45:00Z · gen 3558bb75 · état succeeded · 0 sauts / 1 tir
         → 2026-10-26 22:45 AEDT
         → 2026-10-27 22:45 AEDT
         → 2026-10-28 22:45 AEDT

  [READY] workflows/on-event.nika · on-webhook
         ? cadence on-webhook: its event route fires it, never the clock (not observed)
         · ready in the current configuration with 1 unknown named above; OS activation not verified · authority not acquired
         · DÉCLARÉ — le registre le dit, la machine ne l'a jamais tiré
         → no upcoming slot (a webhook beat fires on its event)

  [UNREADY] workflows/weekly.nika · TZ=Europe/Paris every 2 weeks from 2026-10-05 09:00
         ✗ manqué: { rattraper: N } is not supported by this firer: every fire refuses · `nika serve` keeps it (policy_unsupported)
         · DÉCLARÉ — le registre le dit, la machine ne l'a jamais tiré
         → 2026-11-02 09:00 CET
         → 2026-11-16 09:00 CET
         → 2026-11-30 09:00 CET

  [DORMANT] workflows/vacation.nika · TZ=Europe/Paris lundi 9h07
         · dormant — actif: false · vacation · jusqu_au 2099-12-31
         · DÉCLARÉ — le registre le dit, la machine ne l'a jamais tiré

READY · UNREADY · DORMANT judge the current configuration only — never OS activation, acquired authority or the current window.
nothing was scheduled — `nika arm` READS the file. The machine that fires them is the arming edge.
```

<sub>Captured from nika 0.123.1 right after the fire below, with the wall clock, at the beat's real 22:45 slot in Sydney (11:45 UTC); only the project path is replaced. The French phrases are the binary's own wording.</sub>

| State | Meaning |
| - | - |
| `READY` | The beat's workflow, inputs, model and cost admission hold in the current configuration. It does not prove that an OS unit is installed or that the next fire will succeed |
| `UNREADY` | A blocker, named on a `✗` line: a refused policy, an undeclared input, a workflow that does not check, or a paid image or speech call the price table cannot price under the beat's `plafond:` (`NIKA-1709`). Every fire would refuse |
| `DORMANT` | Suspended with the triple; no slot is computed |

The proof line separates **PROUVÉ** (a recorded fire, read from the beat's
ledger) from **DÉCLARÉ** (the registry says so; the machine never fired it).
`on-webhook` is a declaration: the report shows no clock slot, and
`nika arm fire` records a webhook skip. Sidecar directories that no registry
entry names are reported as orphans and never erased.

A beat that speaks with OpenAI's default voice is the common paid-media case.
Its workflow calls `nika:tts_generate` on `openai` with no `model:`, so the
call bills `gpt-4o-mini-tts`, which the price table cannot price:

```text theme={"system"}
  [UNREADY] workflows/morning-voice.nika · TZ=Europe/Paris 30 7 * * *
         ✗ NIKA-1709 · refusing to start: no catalog price for task `speak` (nika:tts_generate on `openai`, `gpt-4o-mini-tts`) — --max-cost-usd $0.050000 cannot bound unknown spend (`nika check` lists it UNPRICED under COST). The cap comes from --max-cost-usd, the project `ceiling:` or a beat's `plafond:`. Use a model the catalog prices (images: openai `gpt-image-2`, `gpt-image-2.5-sunburst` or `gpt-image-2.5-flare`, gemini `gemini-3.1-flash-image`, `gemini-3-pro-image`, `gemini-2.5-flash-image`, `gemini-3.1-flash-lite-image` or `gemini-nano-banana-2.1`, or any `xai` model; speech: openai `tts-1` or `tts-1-hd`, elevenlabs `eleven_v4`, `eleven_v4_turbo`, `eleven_v3`, `eleven_v3_conversational`, `eleven_multilingual_v2`, `eleven_flash_v2_5`, `eleven_flash_v2`, `eleven_turbo_v2_5` or `eleven_turbo_v2`), the keyless `system` voice for speech, or `local` / `mock`. Only a run with no cap at all (never a beat) makes this call, and its settlement counts it unpriced. (budget_floor)
         · DÉCLARÉ — le registre le dit, la machine ne l'a jamais tiré
```

<sub>Captured offline from nika 0.124.1, with no provider key. In `--json`, the blocker carries the code once on its own field, `kind: budget_floor`, and the sentence alone.</sub>

A beat cannot drop its `plafond:`, so change the call: `model: tts-1` or
`tts-1-hd`, a priced `elevenlabs` model, the keyless `provider: system` voice,
or `local` / `mock`. The same beat with `model: tts-1` reads `[READY]`. A beat
on `gpt-image-1.5` or `gpt-image-1-mini` moves to `gpt-image-2` (the default)
or a GPT Image 2.5 model.

`nika arm --json` prints the same judgment for programs
(`schedule_readiness_version: 2`): one object per beat in `schedules`, with
`status`, `next_fire`, `blockers`, `required_inputs` and the workflow's
`snapshot_digest`. Exit `0` when the registry reads, `2` when it refuses; the
refusal teaches the fix.

## `nika arm fire <label>`: the one firer

```text theme={"system"}
$ nika arm fire nightly-report
fired nightly-report · slot 2026-10-25T11:45:00Z · exit 0 · trace .nika/traces/2026-10-25T11-45-21Z-e685.ndjson
```

One function applies the on-time window, the miss policy, the overlap lock,
the per-fire ceiling and the firing record; the emitted OS units and
`nika serve` both end there, so the policy lives in one place. The resident
`nika serve` also keeps the two catch-up policies this firer refuses
(`rattraper` and `{ rattraper: N }`). The label is
the workflow file's name without its extension (`workflows/doctor.nika` →
`doctor`); a collision takes `-2`, `-3` in file order.

A decision prints **exactly one line on stdout**: `fired …`, `skipped …`
(for example `skipped nightly-report · not-due`), `paused …` or `failed …`,
so a launchd or serve log stays clean. The run's own storyboard goes to
stderr. A registry refusal (exit `2`) explains itself on several lines.

What a fire guarantees:

* The per-beat lock is taken before the decision and held until the
  receipt lands. Delivery is **at-least-once**: a crash between the claim
  and its receipt leaves a durable unmatched claim in `history.ndjson`,
  never a silent double fire. Exactly-once is never promised; keep the
  workflow's effects idempotent and the result is effectively-once.
* Every fire is a fresh run: a run that pauses on a human gate is parked
  with its trace (`paused … · trace …`), never resumed by the firer.
* The beat's `inputs:` are bound like `--var` pairs, and the beat's
  `plafond` is the run's `--max-cost-usd`.

| Exit | Meaning |
| - | - |
| `0` | Fired, or skipped by policy |
| `1` | The run itself failed (the workflow's exit) |
| `2` | The project, the registry, a refused policy or the target workflow file refused; the message teaches the fix |
| `3` | Environment failure |
| `4` | The run paused and was parked with its trace |

What a fire leaves in `.nika/arm/<label>/`:

| File | Role |
| - | - |
| `history.ndjson` | The ledger (`nika/arm-event@1`), hash-chained and verified before every append. A skip is one event; an attempted run is a claim followed by its receipt |
| `head.json` | The chain head the next append must extend (`nika/arm-head@1`: sequence and hash) |
| `last.json` | The last slot-bearing decision (fired, skipped, paused or failed), which the report reads |
| `watermark` | The timestamp of the latest recorded decision |
| `lock` · `ledger.lock` | The per-beat lock held across a fire, and the inner lock that serializes verify and append |

`nika arm migrate` upgrades sidecars written by older engines into this
chained ledger, verifies each chain and rebuilds its projections. It is
idempotent and gives every beat a verdict.

## `nika arm disarm <label>`

Prints the disarm gesture: removing the line from the file is not it;
`actif: false` + `raison:` + `jusqu_au:` is, because that leaves an
auditable trail. `--write` removes only generated unit files and prints the
`launchctl bootout` or `systemctl --user disable --now` command for you to
run; it never runs that command itself.

## `nika arm --emit`: the OS bridge

`--emit launchd|systemd` prints the OS unit that fires the beats instead of
reading the registry; add `--write` to install it:

| Flag | With `--emit` |
| - | - |
| `--write` | Write the unit files instead of printing them |
| `--beat <label>` | Emit the unit of one beat only |
| `--out <dir>` | The directory the units are written to |
| `--mode user\|system` | `user` (the default). `system` is refused in 0.124.3 (« la portée root n'est pas émise », exit `2`): units go to the operator's session (LaunchAgents · systemd --user) |
| `--env-file <file>` | The env file the unit loads: provider keys live there, never in the unit |
| `--nika-bin <path>` | The nika binary the unit invokes |

`launchd` writes a macOS user agent,
`~/Library/LaunchAgents/nika.arm.<project key>.<label>.plist`, and prints the
`launchctl bootstrap` line that loads it; `systemd` writes a user timer and
service pair. A unit never arms a beat that cannot run: while any beat is
`UNREADY`, `--emit` refuses and names it; fix it, suspend it, or emit the
ready beats one by one with `--beat`. Any of these flags without `--emit`
is refused, and so is `--json` with `--emit`: `--json` reports readiness only.

## `nika serve`: the resident firer

Where no OS scheduler exists (a container, a bare server, a VM you own), the
resident loop ends at the same firer as an emitted unit. It also keeps the
catch-up policies `rattraper` and `{ rattraper: N }`, which a `--once` sweep
refuses like `nika arm fire`:

```text theme={"system"}
$ nika serve --once          # one sweep: fire every due beat, then exit
$ nika serve --dry --once    # print `would fire <label> · slot …` for each beat due now; run nothing
$ nika serve                 # stay resident and fire each beat at its slot
```

`--dry` runs and records nothing, and stays resident unless combined with
`--once`. It previews the cadence only: it does not take the beat lock or
apply the missed-run, overlap, cost or execution policy, so `would fire` is
not a promise that the real firer will run. To see upcoming slots, use
`nika arm`.

In a project whose `nika.yaml` arms nothing, `--once` and `--dry` print the
sentence `nika arm` prints, then the `--bind` command and the token recipe for
running workflows over HTTP, and exit `0`:

```text theme={"system"}
$ nika serve --once
nothing armed — /home/alice/project/nika.yaml carries no `arm:` entry
  workflows run on demand over HTTP: nika serve --bind 127.0.0.1:<port> --workflows workflows --token-file .nika/serve.token
  mint the token first: umask 077 && mkdir -p .nika && openssl rand -hex 24 > .nika/serve.token && chmod 600 .nika/serve.token
```

A resident `nika serve` prints the same lines once on stderr and keeps
watching `nika.yaml`, so a beat you arm later still fires.

Startup, registry, clock and loop failures exit `1`. Once the loop runs, each
beat's result is carried by its stdout line and ledger; a completed `--once`
sweep exits `0` even when an individual run failed or paused.

With `--bind`, `--workflows` and `--token-file`, the same process also serves
the authenticated HTTP API, including runtime schedules declared over HTTP
([Server surfaces](https://docs.nika.sh/sdk/operations/server-surfaces.md)). Those schedules live in
the server's state root, separate from this registry
([Schedules](https://docs.nika.sh/sdk/remote/schedules.md)).

> [!WARNING]
>
> **The honesty contract.** Delivery is at-least-once and exactly-once is
> never claimed: a crash between the claim and the receipt leaves a visible
> orphan, not a silent double fire. Keep a fired workflow's effects
> idempotent and the result is effectively-once.


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