Hive

Machines

Pair more machines.

Hive starts on one machine. When the work needs more hands, or something that machine does not have, pair another. A project says what its jobs need, and the queue sends each job to a machine that offers it.

What a job needs, what a machine offers

Machines are not alike. An iOS app needs a Mac with Xcode, a model evaluation wants a GPU, and most jobs want nothing in particular. So a job says what it needs, a machine says what it offers, and both use the same plain lowercase words, with no fixed list: macos, linux, arm64, amd64, xcode, docker, gpu, android, the name of a tool.

A job fits a machine when every word it needs is among the words the machine offers. A job that needs nothing fits every machine that is not reserved.

What a machine offers is its operating system, its chip and its labels. Hive reads the first two by itself and finds xcode and docker on its own. You add the rest:

hive settings set machine.labels gpu,android   # what this machine offers, beyond what Hive finds
hive executor label gpu-box +cuda              # add a word on a paired machine
hive executor label gpu-box -cuda              # remove a word
hive executor label gpu-box +cuda,-gpu         # add one word and remove another
hive executor list                             # every machine, its slots and what it offers

What a job needs comes from its project, and one job can differ:

hive init ~/code/ios-app --needs macos,xcode   # every job of the project needs a Mac with Xcode
hive job needs JOB_ID linux,gpu                # one waiting job that needs something else
hive job needs JOB_ID -                        # this one job may run anywhere after all

The same words can live in the repository, on the needs: line of .hive/hive.yaml. In the console, a project's Runs on panel shows the words, which machines fit, and a warning when none does.

Where a job goes

The queue fills free slots in an order that protects the scarce machines. Reserved machines come first, and take only the jobs that need them. Then come the machines kept for certain projects, then the machine that offers the least: a plain Linux machine before the one with a GPU, before the Mac with Xcode. The scarce machine stays free for the work only it can do.

Some jobs never leave the machine Hive runs on, whatever they need: the lead, the review and the reflection work against the store, and the store is here.

hive settings set machine.reserve on   # this machine takes only the jobs that need something it offers
hive executor reserve gpu-box          # the same for a paired machine; --off releases it

A job whose needs no machine offers waits in the queue, and Hive asks you once: pair or label a machine that offers them, or change the needs.

Pair a Linux machine over SSH: hive pair

hive pair sets up a Linux machine as one of yours, over the SSH login of an admin on that machine. The name is required, and the admin needs passwordless sudo. It refuses anything but Linux: a Mac, or any other machine, joins with hive-hand, in the next section.

hive pair ADMIN@HOST --name NAME [--workdir /srv/hive] [--workers N] [--projects a,b|*]

It reads the machine first and refuses, before it changes anything, when the machine is not fit: not Linux, no passwordless sudo, a work folder that already holds clones.

It copies a Linux hive to the machine. When Hive itself runs on Linux with the same processor, it sends its own program. Otherwise it needs one from you: set HIVE_HANDS_BINARY to a Linux hive for that machine's processor (the hive inside the release's Linux archive), or put that file beside your hive as hive-linux-amd64 or hive-linux-arm64. From a checkout of Hive's source it can cross-build one. With none of these it stops and says so.

Then it changes these things, and every step reports kept or done, so pairing again is safe:

  • On the machine: a hive user; the program as /usr/local/bin/hive-hands, with /usr/local/bin/hive linked to it; a git config and mise in that user's home; a work directory; one line in that user's authorized_keys that lets Hive's key run the hands commands and nothing else; and an sshd drop-in, /etc/ssh/sshd_config.d/60-hive-hands.conf, after which sshd is reloaded.
  • On your machine: a Host block in ~/.ssh/config, and the machine's host keys in ~/.ssh/known_hosts.

A newly paired machine has no model login and takes no work until it has one. Log it in, then probe it: a machine that passes the probe takes work. --workers is only the starting count: each probe reads the machine's cores and memory and sets its slots to the smaller of the cores and one run per 3 GB.

hive pair ADMIN@HOST --name NAME --inspect    # read the machine and print the scripts; apply nothing
hive executor login NAME --admin ADMIN@HOST   # give the machine a model login; --with-token reads a token on stdin
hive executor probe NAME                      # check a machine again
hive remove executor NAME                     # the undo

Enrol any machine: join codes and hive-hand

hive-hand is a second, small program. It holds only what a machine needs to run the jobs it is handed, and none of what decides which jobs exist. A machine with it joins once and then calls out for work. There is no open port on it, no change to its SSH server, and no key of yours stored on it.

In the console, Machines → Add a machine → Run one command on it → Get a join code shows a six-word code, good for ten minutes and one join, with the line to run on the machine. Here it is with an address the machine can reach in place of the one the console shows:

hive-hand join --brain https://hive.example.com amber-river-cobalt-maple-orbit-lantern
hive-hand dial          # every later start: keep this running (a launchd or systemd service)

join makes a device key on the machine, sends only its public half, and then dials in itself: it stays connected and does not return. dial is what you keep running on every later start. It signs a one-time challenge with that key and then waits for work; while the console cannot be reached it tries again, waiting longer each time. The Machines page shows the machine's last call and a Revoke button: a revoked machine is refused, and coming back takes a new code.

hive-hand enrols the machine and carries the jobs. An agent itself runs on the harness, which is in hive, so a machine that should take work also needs hive on its PATH and a model login of its own. The installer puts both programs in place: once as it is, once with --hand.

--brain is the address the machine reaches your Hive on. The line the console shows carries the address your browser used, so it usually reads http://127.0.0.1:8765: change it to an address the other machine can reach. The console listens on 127.0.0.1 only, so another machine reaches it only through something you set up on the machine Hive runs on: an SSH tunnel, or a proxy with TLS there. A private network alone does not reach a port bound to 127.0.0.1. A tunnel reaches the whole console, not only the routes hive-hand uses, so keep it between your own machines. Under a name of your own, through a proxy, the console answers the routes hive-hand uses and nothing else, until you list that name in the setting hub.hosts: it refuses every other host name, so that a web page cannot reach it by pointing a name at 127.0.0.1.

An SSH tunnel is the short way. On the machine that joins, forward a port of its own to the console and name that port. Keep the tunnel up for as long as the machine should take work:

ssh -N -L 8765:127.0.0.1:8765 YOU@HOST &                # HOST is the machine Hive runs on
hive-hand join --brain http://127.0.0.1:8765 CODE       # this machine's port 8765 now reaches the console

When a machine goes quiet

A machine that stops answering gets no new work. Hive probes it again after a minute, waits longer after each probe that fails, up to thirty minutes, and puts it back in rotation with the first probe that passes. A job whose machine fell silent in the middle of a run goes back to the queue.

Step by step

This page says how it works. The guides say what to click and what to type:

  • Add a second machine. Pair a Linux machine over SSH, or join a Mac or Linux machine with a code, so jobs can run there. Then say what a project's jobs need from a machine.

The full reference

  • Machines: needs and offers, pairing, the join protocol, heartbeats, moving a project, removing projects and machines.
  • The Machines page of the console.
  • The runner: how jobs are leased and what keeps the machine healthy.
  • Security notes: where code runs and where data lives.