> For AI agents: the complete documentation index is available at https://docs.hod.sh/llms.txt, the full documentation bundle is available at https://docs.hod.sh/llms-full.txt.

# Runners

The runner is its own binary, `hod-runner`. The Compose runners are the image's (`hod-runner start`): they start job containers on the host's Docker through its socket, and keep workspaces in `/var/lib/hod-runner` and `/var/lib/hod-runner-unprotected`. More runners can run on any Linux machine that reaches the server:

```sh
HOD_RUNNER_TOKEN=<token> hod runner start --server https://ci.example.com
```

## Runner trust

Every runner is **protected** or **unprotected**, as the registration token it joined with says. The server sends the jobs of **default-branch and tag runs** only to protected runners, and **every other job** (pull requests, other branches, manual runs of them) only to unprotected ones. Runners can't choose: the token decides.

Why: code on the default branch and tags has been reviewed, and those runs get the release secrets, OIDC identity and push rights. A pull request's code hasn't been reviewed yet. A job with `docker: true` runs a privileged container, and a privileged container can take over its machine. If a pull request's job could run where release jobs run, it could read their secrets and job tokens, or plant code in the caches they use. GitLab's protected runners and Buildkite's clusters keep the two apart the same way.

- **Put unprotected runners on machines of their own**: other VMs or hosts. Two runners in containers on one Docker host don't keep them apart, since both reach the same Docker. The Compose quick start runs both on one machine, so its unprotected runner doesn't allow `docker: true`; those jobs wait, with a reason saying so, until an unprotected runner that allows Docker joins.
- **Protect the default branch and release tags on your forge** (required reviews, no direct pushes, tag rules). Hod trusts what reaches them; if anyone can push to the default branch, its runs are no more trustworthy than a pull request's.
- **Tokens.** `HOD_RUNNER_TOKEN` registers protected runners and `HOD_RUNNER_TOKEN_UNPROTECTED` unprotected ones; `hod runner tokens create --trust protected|unprotected` makes more. A job that no online runner of its kind can take waits, and says why: `no online unprotected runner offers capability dind: pull request and other-branch jobs run only on unprotected runners`.

On a second machine, for pull requests:

```sh
HOD_RUNNER_TOKEN=<unprotected token> hod runner start --server https://ci.example.com --allow-docker
```

## Adding a runner

`hod runner start` runs `hod-runner start` with the rest of its arguments, and the server and TLS settings `hod login` saved. See `hod runner start --help` (or the [runner reference](https://docs.hod.sh/reference/runner.md)) for `--labels`, `--slots` and `--network host`. A runner also reads `HOD_GIT_PROTOCOLS` (`--git-protocols`, `https` by default): the URL schemes it may fetch jobs' repositories with.

- **Getting hod-runner.** `hod runner start` uses a `hod-runner` on `PATH`. Without one, it installs the server's own build into `~/.local/share/hod/runners`, after asking on a terminal; in scripts and services, run `hod runner install` first. Each server hands out the builds of its own version, for x86_64 and aarch64 Linux, at `GET /api/v1/runner-downloads` (no token needed). The image has them in `/usr/share/hod/runners/<target>/hod-runner`; point `HOD_RUNNER_DOWNLOADS` at another directory laid out the same way. The release archives (`hod-runner-<version>-<target>.tar.gz`) and the image's `/usr/local/bin/hod-runner` work too, with `hod-runner start --server URL` directly. An installed runner doesn't update itself: after upgrading the server, restart it with `hod runner start` to install and run the new build. That asks on a terminal; a service runs `hod runner install` before each start (systemd's `ExecStartPre=-…`, so a server that's down doesn't stop it), or it stops at the new version until someone does.
- **What runner machines need.** Docker, for job containers. Not git: the runner checks out jobs' commits itself. Jobs on the host executor that call git need it there, like any other tool they use.

## Registration and identity

- **Registration tokens.** `hod runner tokens create --trust protected|unprotected [--pool P] [--one-time] [--expires-in 7d]`.
- **Identity.** A runner registers once and keeps its identity, an Ed25519 key, in `--state-dir` (`~/.local/state/hod/runner`), so it needs the registration token only the first time. An admin removes a runner with `DELETE /api/v1/orgs/{org}/runners/{id}`.
- **Ephemeral runners.** `hod runner start --ephemeral` takes one job and exits, keeping its key in memory. With a one-time token, no long-lived secret stays on the machine.

## Jobs on a runner

- **Docker in jobs.** Jobs with `docker: true` get a Docker daemon of their own in a privileged container, and only run on runners started with `--allow-docker`. The Compose protected runner allows it; allow it on an unprotected runner only on a machine of its own ([Runner trust](#runner-trust)).
- **Lost jobs.** If a runner crashes or loses its network, its job goes back to the queue once its lease expires (about a minute), up to three attempts.
- **Host jobs and secrets.** Jobs that run on the host (macOS and Windows runners, `runs-on: [macos]` without an image) share the runner's OS user. A host job that has secrets runs alone on its runner, whatever its `--slots`. A host job without secrets can still run beside a Docker job that has some and reach its container through Docker: if that matters, keep host jobs on runners of their own (`--labels`).
