---
title: "af-server"
description: "Atoll Forge server"
---

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

# af-server

<!-- Generated by tools/gen-reference.mjs from `af-server --help`. Change the help text in crates/atoll-forge-server/src/main.rs, then run `npm run gen:reference`. -->

Serves the forge from a data directory to `af` clients and agents, over WebTransport with a WebSocket fallback, both over TLS. A forge runs as a single node or as a cluster of nodes; see --enrollment and --join to add a node to a cluster.

Durations are written as a whole number with a unit: `ms`, `s`, `m`, `h` or `d`, such as `250ms`, `10s` or `14d`.

## Usage

```text
af-server [OPTIONS]
```

## Options

- `--listen <LISTEN>`

  Address for WebSocket connections (TCP), the fallback for clients without WebTransport

  Environment variable: `AF_LISTEN` · Default: `127.0.0.1:7777`

- `--quic-listen <QUIC_LISTEN>`

  Address for WebTransport connections (UDP); defaults to the --listen address

  Environment variable: `AF_QUIC_LISTEN`

- `--data-dir <DATA_DIR>`

  Directory for the server's data; created if missing

  Defaults to `af-data`, or to `af-dev` with --dev. The server writes a `.gitignore` that ignores everything into it, so a git checkout or `af` workspace it sits in never takes the server's files as its own.

  Environment variable: `AF_DATA_DIR`

- `--dev`

  Run a local development server, ready to use with no setup

  Starts a single node on this machine that needs no identity provider, recovery keys or certificate. A local developer, `dev@localhost`, is signed in at once as the first administrator. The vault unseals itself from a key file in the data directory, and the server keeps its self-signed certificate there so that its hash stays the same across restarts. The server prints the environment `af` needs and writes it to `dev/env` in the data directory, ready to `source`.

  A data directory records whether it is a development server's or an ordinary one's, and each refuses the other's: an ordinary start never opens a directory that records a --dev origin, and --dev opens only its own or a new one. A directory from a build that recorded no origin opens only as an ordinary server's; --dev refuses it.

  For development only: the server listens on loopback addresses only, and anyone who can read the data directory can act as its administrator.

- `--tls-cert <TLS_CERT>`

  TLS certificate chain, in PEM, for WebTransport and WebSocket connections

  Both use TLS 1.3. Without a certificate, the server generates a self-signed one for localhost and logs its hash, which clients pin with `af --cert-hash`.

  Environment variable: `AF_TLS_CERT`

- `--tls-key <TLS_KEY>`

  Private key, in PEM, for --tls-cert

  Environment variable: `AF_TLS_KEY`

- `--committer-name <COMMITTER_NAME>`

  Committer name on commits the server writes, such as rebases

  Environment variable: `AF_COMMITTER_NAME` · Default: `"Atoll Forge"`

- `--committer-email <COMMITTER_EMAIL>`

  Committer email on commits the server writes

  Environment variable: `AF_COMMITTER_EMAIL` · Default: `forge@localhost`

- `--log-origin <LOG_ORIGIN>`

  Origin of the receipt log: a host and path, such as `forge.example.com/atoll`

  The receipt log is the forge's tamper-evident log of signed records. Its origin is the first line of each of its checkpoints.

  Environment variable: `AF_LOG_ORIGIN` · Default: `localhost/atoll-forge`

- `--repository-uri <REPOSITORY_URI>`

  URI that names the forge in receipts

  Receipts name a repository by this URI followed by its organization and its own name, such as `<uri>/operator/main`.

  Environment variable: `AF_REPOSITORY_URI` · Default: `https://localhost/atoll-forge`

- `--domain <DOMAIN>`

  Domain under which each organization has its own host, such as `forge.example`

  Organization `acme` is then served at `acme.forge.example`, with one wildcard certificate for all organizations. Without a domain, every host name reaches the operator's organization.

  Environment variable: `AF_DOMAIN`

- `--oidc-issuer <OIDC_ISSUER>`

  OpenID Connect issuer that the operator organization's people sign in through

  Give it exactly as the `iss` claim of its tokens names it. Without an issuer, nobody can sign in to the operator's organization. Other organizations' issuers are set when they are created with `af create-organization`.

  Environment variable: `AF_OIDC_ISSUER`

- `--oidc-client-id <OIDC_CLIENT_ID>`

  The forge's client ID at the issuer, the audience of its tokens

  Environment variable: `AF_OIDC_CLIENT_ID`

- `--oidc-tenant <OIDC_TENANT>`

  Tenant claim, as `claim=value`, for an issuer that many organizations share

  Only tokens that carry this claim with this value are accepted: for example `hd=example.com` for Google, or `tid=<tenant id>` for Microsoft Entra ID.

  Environment variable: `AF_OIDC_TENANT`

- `--oidc-second-factor <OIDC_SECOND_FACTOR>`

  `amr` values (RFC 8176) that show a person signed in with a second factor; any one is enough

  Environment variable: `AF_OIDC_SECOND_FACTOR` · Default: `mfa`

- `--oidc-second-factor-by-policy`

  Declare that the identity provider requires a second factor for everyone who signs in

  Use this for a provider whose tokens don't say how a person signed in (no `amr` claim). Each sign-in's record notes that it relies on this declaration.

  Environment variable: `AF_OIDC_SECOND_FACTOR_BY_POLICY`

- `--first-administrator <FIRST_ADMINISTRATOR>`

  Verified email of the person who becomes the first administrator when they sign in

  Applies only while the forge has no administrator.

  Environment variable: `AF_FIRST_ADMINISTRATOR`

- `--two-administrators`

  Require a second person: another administrator for every administrator's request, and someone other than the change's own line for each approval and clearance

  The four-eyes principle, for the platform and every organization. A change of a role, a folder, a key, a runner or a node, a purge or an import, asked for by an administrator, waits until another administrator approves it, and no one approves a request of their own. The forge's only administrator still acts alone, each such change an exception reports list. No approval or clearance of a change counts from the change's own line, and nobody approves a release their own line asked for. Off by default: an administrator's own word is enough, a person may approve and clear their own changes and approve their own releases, and reports list each as an exception.

  Environment variable: `AF_TWO_ADMINISTRATORS`

- `--organization <ORGANIZATION>`

  Name of the operator's organization, the organization that runs the forge

  The cluster's first start creates it, with the first administrator as its administrator. The name is also the first label of the organization's host name.

  Environment variable: `AF_ORGANIZATION` · Default: `operator`

- `--first-repository <FIRST_REPOSITORY>`

  Name of the organization's first repository, created on the cluster's first start

  Environment variable: `AF_FIRST_REPOSITORY` · Default: `main`

- `--raft-listen <RAFT_LISTEN>`

  Address for cluster (Raft) traffic from the forge's other nodes

  Each node proves its identity with its node key.

  Environment variable: `AF_RAFT_LISTEN` · Default: `127.0.0.1:7778`

- `--raft-advertise <RAFT_ADVERTISE>`

  Address, as host:port, where other nodes reach this node's cluster port

  Kept in the node's record. Defaults to the --raft-listen address.

  Environment variable: `AF_RAFT_ADVERTISE`

- `--client-advertise <CLIENT_ADVERTISE>`

  Address, as host:port, where clients reach this node, if they are to be sent to it

  Kept in the node's record, which the cluster's first start makes, and printed by --enrollment for a node that joins. A client that asked a node that does not lead the group it waits on is sent to this address of the node that does, to wait there; with none it asks again where it is, or looks every few seconds. Never the --raft-advertise address, which is the cluster's own.

  Environment variable: `AF_CLIENT_ADVERTISE`

- `--node-name <NODE_NAME>`

  Name of this machine, kept in the node's record for reference; defaults to the host name

  Environment variable: `AF_NODE_NAME`

- `--machine-id-file <MACHINE_ID_FILE>`

  File to read this machine's id from, instead of /etc/machine-id

  The node's record keeps the machine, the HMAC-SHA256 of a fixed text keyed by the id, in hex, never the id itself; the forge refuses an organization's runner on the machine of one of its nodes. A development forge and a runner on one host share /etc/machine-id: name another file for one of them (at least 16 characters that are not whitespace), and a warning on standard error says the default was not used. Without this option, a machine that has no usable /etc/machine-id is on no machine, and says so on standard error.

  Environment variable: `AF_MACHINE_ID_FILE`

- `--recovery-key <RECOVERY_KEY>`

  Public recovery key file of a key holder, as written by `af vault key`

  Used at the cluster's first start; give one for each holder, by repeating the option or separating files with commas. The cluster's key-encryption key is kept only in memory, protected by an unseal key split into one share for each holder. A node that restarts while no other node of its cluster is running stays sealed until enough holders unseal it with `af vault unseal`.

  Environment variable: `AF_RECOVERY_KEYS`

- `--recovery-threshold <RECOVERY_THRESHOLD>`

  Number of recovery key holders needed to unseal the cluster

  Must be 1 with a single key, and at least 2 otherwise.

  Environment variable: `AF_RECOVERY_THRESHOLD`

- `--dev-key-file`

  Keep the cluster's key-encryption key in a file, for development only

  At the cluster's first start, stores the key in `keys/kek` in the data directory, next to the data it protects, instead of sealing it with recovery keys.

  Environment variable: `AF_DEV_KEY_FILE`

- `--enrollment`

  Print the `af` command that enrolls this machine as a cluster node, then exit

  Creates the node's key and sealing key in the data directory first, if it has none. A platform administrator runs the printed command; the node then joins with --join.

- `--join <JOIN>`

  Join a cluster through the forge whose WebSocket is at this address, as host:port

  Use with a new data directory, on a machine that a platform administrator has enrolled with the command --enrollment printed, and with --join-as naming the node. Once joined, the node restarts without this option.

  Environment variable: `AF_JOIN`

- `--join-as <JOIN_AS>`

  ID of the joining node, in hex, as given when its enrollment took effect

  Environment variable: `AF_JOIN_AS`

- `--join-host <JOIN_HOST>`

  Host name of the operator's organization, if it differs from the --join host

  Environment variable: `AF_JOIN_HOST`

- `--join-cert-hash <JOIN_CERT_HASH>`

  SHA-256 of the forge's self-signed certificate, in hex, to trust when joining

  Without it, the certificate must chain to the system's trusted roots.

  Environment variable: `AF_JOIN_CERT_HASH`

- `--min-heartbeat-ttl <MIN_HEARTBEAT_TTL>`

  Shortest heartbeat interval (TTL) given to runners; 10s by default

  A runner must send a heartbeat within its TTL to keep its jobs.

  Environment variable: `AF_MIN_HEARTBEAT_TTL`

- `--max-heartbeats-per-second <MAX_HEARTBEATS_PER_SECOND>`

  Most runner heartbeats a repository's leader accepts per second; 50 by default

  Runners are given longer TTLs as needed to stay under this rate. The leader is the node that currently coordinates the repository.

  Environment variable: `AF_MAX_HEARTBEATS_PER_SECOND`

- `--heartbeat-grace <HEARTBEAT_GRACE>`

  Extra time beyond a runner's TTL before its jobs are queued again; 10s by default

  Environment variable: `AF_HEARTBEAT_GRACE`

- `--failover-heartbeat-ttl <FAILOVER_HEARTBEAT_TTL>`

  Runners' TTL after a node becomes a repository's leader; 5m by default

  Gives runners time to find the new leader before their jobs are queued again.

  Environment variable: `AF_FAILOVER_HEARTBEAT_TTL`

- `--retention-window <RETENTION_WINDOW>`

  How long a finished change's snapshots and operation history are kept; 14d by default

  After this, garbage collection may remove them.

  Environment variable: `AF_RETENTION_WINDOW`

- `--gc-grace <GC_GRACE>`

  Minimum time an unreferenced object is kept after it was written; 14d by default

  Protects objects that uploads in progress still rely on from garbage collection.

  Environment variable: `AF_GC_GRACE`

- `--gc-every <GC_EVERY>`

  How often each repository's leader runs garbage collection; 1h by default

  Environment variable: `AF_GC_EVERY`

- `--worker-threads <WORKER_THREADS>`

  How many async worker threads the node runs, 1 to 1024; one for each available CPU by default

  The threads that carry the node's requests, its Raft and its lander. Several nodes on one machine contend for its CPUs with a worker for each: give them counts whose sum does not exceed the machine's physical cores. The blocking threads, the repository's thread, the code search's and the Raft log's are not set by this. Read at start.

  Environment variable: `AF_WORKER_THREADS`

## Examples

```sh
A development forge, on this machine only:
  af-server --dev
The first node of a forge, its people signing in through an identity provider and its key
recovered from three people's shares, any two of them:
  af-server --data-dir /var/lib/af-server --listen 0.0.0.0:7777 --quic-listen 0.0.0.0:7777 --tls-cert /etc/af-server/cert.pem --tls-key /etc/af-server/key.pem --oidc-issuer https://accounts.google.com --oidc-client-id CLIENT_ID --oidc-tenant hd=example.com --first-administrator ada@example.com --recovery-key ada.pub,bob.pub,carol.pub --recovery-threshold 2 --raft-listen 0.0.0.0:7778 --raft-advertise forge-1.example.com:7778
A second node: its keys, and the command that enrolls it, then its join once enrolled:
  af-server --data-dir /var/lib/af-server --raft-advertise forge-2.example.com:7778 --enrollment
  af-server --data-dir /var/lib/af-server --join forge-1.example.com:7777 --join-as NODE_ID --raft-listen 0.0.0.0:7778 --raft-advertise forge-2.example.com:7778
```

Source: https://docs.forge.workreef.dev/reference/af-server/index.mdx
