# swarmfile-runner

`swarmfile-runner` runs the engine in **runner mode**: it sets `SWARMFILE_RUNNER_MODE=true` (when the variable isn't already set), then re-execs the sibling `swarmfile-engine` binary with the same arguments and standard I/O. It has no subcommands or flags of its own - every engine flag passes straight through - and it runs the real engine boot path (config, single-instance lock, lifecycle) exactly as `SWARMFILE_RUNNER_MODE=true swarmfile-engine` would.

It exists so the headless CI role reads as its own tool rather than "the engine with an env var". For what a runner does and how to wire it into a CI system, see [Runner (Headless CI)](https://swarmfile.com/docs/guides/runner-as-ci).

Because it re-execs the engine, `swarmfile-runner --help` is the engine's help. The pass-through flags:

| Flag | What it does |
|---|---|
| `--build-info` | Print the enabled cargo features and target architecture, then exit. |
| `--status` | Engine, hub, peers, and pending work at a glance (works while another engine holds the lock). |
| `--capabilities` | The compiled feature set of this binary. |
| `--print-env-vars` | The resolved `SWARMFILE_*` values this build consumed, secrets redacted. |
| `--pause` / `--resume` | Pause or resume sync on a running engine without unmounting. |
| `--quit` | Ask the running engine to drain and stop. |
| `--pin` / `--unpin` / `--list-pins` / `--verify-pins` | Offline cache pins: add, release, list, and verify. |
| `--prepare-offline [SECS]` / `--return-from-offline` | The engine-level Pack & Go pair - see [Working Offline](https://swarmfile.com/docs/guides/offline-working). |

See [Engine Config File → Engine command-line flags](https://swarmfile.com/docs/reference/config-file#engine-command-line-flags) for the full descriptions.

## Environment

| Variable | Description |
|---|---|
| `SWARMFILE_RUNNER_MODE` | Forced to `true` when unset. An explicit value is preserved, so `SWARMFILE_RUNNER_MODE=false swarmfile-runner` still runs in normal mode |
| `SWARMFILE_API_KEY` | Repository API key (`sf_key_…`) the runner authenticates as. The hosted hub refuses to start with a PAT unless `SWARMFILE_RUNNER_ALLOW_PAT=1` (jobs run, but their reports are refused and the Runs tab stays empty) |
| `SWARMFILE_ORG_ID` | Org that owns the repository. Optional with a repository API key (the runner resolves it from the repository API key) or when the hub URL already ends in `/orgs/<id>`; otherwise required, including with a PAT or an older hub |
| `SWARMFILE_REPOSITORY_ID` | Repository the runner serves. Optional with a repository API key (resolved with the org) |
| `SWARMFILE_BRANCH` | Branch the runner tracks (defaults to the repository's default branch) |

Runner mode deliberately serves no control socket. A driverless CI host needs no FUSE - `materialize` and runner mode never call the mount path.

## Acquiring it

- **Linux** - the `.deb` installs it at `/usr/bin/swarmfile-runner`, next to `swarmfile-engine`.
- **macOS** - it ships inside `Swarmfile.app/Contents/MacOS/swarmfile-runner`, next to the bundled engine, with a `/usr/local/bin/swarmfile-runner` symlink on a prod install.
- **Windows** - the MSI installs it next to `swarmfile-engine.exe` in the install folder, and the app-only zip carries it.
- **Keep it next to the engine.** It must sit in the same directory as `swarmfile-engine`, because it re-execs the sibling resolved next to its own executable; the installers put it there.
- **Equivalent without the alias** - on any engine binary, `SWARMFILE_RUNNER_MODE=true swarmfile-engine` behaves identically.

## Example

```bash
SWARMFILE_API_KEY=sf_key_... SWARMFILE_ORG_ID=org_abc123 \
  SWARMFILE_REPOSITORY_ID=proj_xyz789 swarmfile-runner
```

Because it re-execs the engine, the process's exit code and output are the engine's. If the sibling `swarmfile-engine` is missing, the alias prints an error and exits `127`.
