Skip to content
docs/concepts
Get started

Workers, and where code actually runs

A worker is a machine that runs sessions. The controller’s own machine is one, and so is every other machine you enroll.

The controller is the daemon you run. It holds all the state: the database, the terminals, the board, reviews and plans. It is the only thing worth backing up.

A worker runs processes. It holds no durable state of its own, and losing one costs you the sessions that were on it, not your history.

The controller’s machine is a worker like any other, and by default it is the only one. pm daemon --no-local-worker turns that off for a controller that should dispatch work but never run it.

The Manage → Workers page mints a single-use, short-lived token and shows the exact command. The two shapes are:

Terminal window
# the worker opens the connection — the usual case, including behind NAT
pm worker --controller <url> --token <enrollment>
# the controller opens it instead, for a worker that cannot dial out
pm worker --listen <host:port> --token <enrollment>

Either way the link is mutually authenticated, and the controller reaches workers on its own listener — --worker-listen, 127.0.0.1:7677 by default — which is a different address from the dashboard’s.

--name identifies a worker on the machine it runs on, and each name enrolls separately, with its own key. One machine can therefore appear as several workers:

Terminal window
pm worker --name build --controller <url> --token <enrollment>
pm worker --name review --controller <url> --token <enrollment>

That is how you give a noisy job its own worker without buying a second machine. A bare pm worker --name build later reconnects that one. With one worker configured on the machine, --name is optional and every pm worker command means that one.

pm worker --sandbox runs the worker inside a container instead of as this process. One container is one worker and one enrollment.

Terminal window
pm worker --sandbox --dir ~/src/acme

--dir bind-mounts a directory into it, and a bare path mounts at the identical absolute path, so a session spawned in that project resolves its working directory on either side.

The container takes the worker’s name, pm-worker-<name>, and its settings are stored under that name. pm worker list shows them, pm worker modify changes them, and pm worker restart rebuilds the container on the change.

Adding a second machine covers this properly, including what the container does and does not protect you from.

A session’s worker is fixed when it spawns and never changes. The worker chip on the spawn popover picks one, offering only the workers the project is configured for — anything else is refused with the valid choices listed.

A project carries a path per worker, so the same project can live at /Users/you/src/acme on your laptop and /srv/acme on a build machine. A spawn is refused rather than guessed when the project has no path on the chosen worker, when that path does not exist there, or when the worker is offline.

The sessions on it stop, because the processes were there. The controller keeps the session records, their transcripts and everything on the board. Failure behavior covers what reconciliation does when it comes back.