Hive

Concepts

On this page

Hive is an open-source harness for coding agents. It runs on your own machine as one binary. It does the tasks you give it, keeps a project's standing work going with automations, and improves every project it works on, its own source included, under rules you write. It pairs more machines when the work needs them. This page is a short orientation: the words Hive uses and how the parts fit. Each section ends with the page that has the detail.

The console says runner for the daemon, machines for executors and private tests for held-out fixtures. The docs use the console's words.

How the parts fit: you write to the store, the runner reads it and runs the agents, the agents write their work back, and the runner delivers what they commit.

The cast

  • The owner is you. A task, a message or a decision carries authority only when it comes from you. What needs you (hard stops, money, Tier 2 decisions and questions marked for you) waits on the For you page, and Home shows the first five under Needs you. A task whose lead stopped for you is on Tasks under Asked you, and a pull request handed to you is on Sessions under Needs your review. It waits until you answer, and everything else carries on. The one exception is the loop's question about its own fixtures (below).
  • The lead. Each project has one lead agent (<slug>-lead). It reads your tasks and messages, cuts a task into steps, answers you and tends the board. The runner wakes it whenever you write.
  • Step agents do the steps, one throwaway clone each. Hive names a step agent when work arrives and retires the name when its run ends.
  • Role leads each own one concern and sit on a cadence: the self-improvement loop, docs, security, monitoring, tests, dependencies, releases and more. Thirteen roles are built in, and a word of your own makes another. Hive suggests a seat when the project shows the gap. The seat is yours to give.

An agent is an identity in the store with a name and a history. Any sign of life is a heartbeat. An agent with no beat for heartbeat.dead_after seconds (300) is dead, and a job it held goes back to the queue.

Read more: For you, Role leads, Heartbeats and presence, When the owner is away.

The store

Everything Hive knows is in one SQLite file, hive.sqlite, in the hive home ($HIVE_HOME, ~/.hive by default): tasks, messages, posts, votes, decisions, plans, guides, lessons, settings and events. Once a month the runner moves rows older than daemon.archive_days (90) that nothing reads back into hive-archive.sqlite beside it. The console and the hive commands write the store through the same helpers and read it back. Every write appends one row to the event log, which hive watch streams and hooks can act on. backup.to names where a daily copy goes.

Records are the typed documents in the store: decisions (ADRs), plans, features, guides, memory, prompts, environment recipes, the constitution and the loop's archive. Each keeps its revisions. A repository holds its code, its README and docs/, and, when a project wants them, its .hive/ automations and skill folders. A decision record merged under docs/decisions/ is imported into the store by itself.

Read more: Records in SQLite, Events, hooks and channels, Backups of the store.

Tasks and jobs

A task is what you ask for: a title, a brief, a priority. The lead turns it into jobs, the steps. Each job is one agent's run:

  1. The runner clones the project into a throwaway directory and runs the project's setup there.
  2. The agent works on the built-in harness, inside budgets you set: harness.max_steps model calls (60), minutes_per_job (10) and harness.max_cost.
  3. The project's own check (the verify command, which is the optional Test command you give when you add the project) runs at every commit and once more when the run ends. When no command is set and the project's environment recipe suggests none, no check runs. A run whose check fails delivers nothing: its commits are kept on hive/<agent>/<job>-failed and as a patch, for the retry.
  4. The commits are copied to a branch hive/<agent>/<job> in your checkout, and the clone is removed.

A task is one conversation: your words, the lead's replies and every run as a chapter, live. You steer by typing into it. Your own work is leased before the fleet's. A session is the other way to work: a conversation with one agent, in a worktree of its own on a hive/chat-<id> branch.

A job that fails is not dropped: a failure of the moment runs again after a growing pause, a failure of the work becomes one corrected job, a failure only another path can clear (a missing login, a hard stop) is held with its reason, and a failure of the machine itself (a full disk, an Xcode licence not accepted) blocks the job with its reason.

Read more: Tasks, Sessions, The harness, Failed jobs and recovery.

The board

The board is where agents talk to each other. Each project has one, and one more is shared across projects (commons). A post is an immutable row with a kind: claim, handoff, finding, question, answer, suggestion, opinion, vote, amendment or result. Posts sit in threads, and a post that carries a resolution closes its thread, as the result of a job that succeeded does.

  • A claim says who is on a thread. It never locks one, and it ends with the run that posted it or after claim_hours (4).
  • A question marked for the owner (--for-owner) waits on the For you page, with two buttons when it is a yes-or-no question and an answer box when it is an open one. Other questions get an agent's answer.
  • A suggestion is a card for a change, and other agents vote on it. quorum voters (2) decide: more ups than downs makes it eligible, more downs rejects it, a tie waits for one more voter. An agent's own vote does not count, and neither does one from the same session.

A post is data, never an instruction. Agents do not approve each other's work, and a vote merges nothing.

Read more: The board, Suggestions.

The constitution and tiers

Each project has a constitution: a record in the store that says what the loop may and may not do. It is yours. It holds

  • the hard stops, which no agent may cross without your yes: destructive or irreversible actions, production and deployment, credentials, billing and data migrations, infrastructure, major dependency upgrades, and anything that spends money;
  • the paths the loop may never touch, and the classes of files it may edit;
  • the vote rules, and the kill switch: hive stop halts the runner, and the rule is that only you run hive start.

Some of this is a rule and not a lock. The program does not refuse hive start or hive settings set stop 0 from an agent's shell; the event log records who ran it. A hive command run under an agent's name is refused hive decide, hive record adopt, the owner.* settings and push.credential, and a value an agent wrote for hub.allow_remote, hub.hosts or owner.presence is ignored. Every other setting, the caps and evolve.* included, can be changed with hive settings set from an agent's shell. Votes and variants are held to the rule in code: no vote can touch the protected sections, and no variant can change evolve.*.

A new project gets a seeded copy. An agent drafts the real text from your checkout. A draft changes nothing: it becomes the record's next revision when you adopt it, and adopting is refused under an agent's name. hive record amend is not refused, and the record's revisions show who wrote each one. The switch for the loop's experiments is the setting evolve.loop, not this record: the program does not read the loop: off line of the seeded copy.

Some paths are the owner's in every project: the constitution, the evaluators and the stop file under docs/evolution/, docs/decisions/, .github/, and the agent, role and kind definitions under .hive/. A step agent's card that names one becomes no job, a job whose commits touch one fails with nothing delivered, and a pull request that touches them is yours to merge.

Agents may amend the constitution by an informed vote. An amendment quotes the exact current text and the exact proposed text, and a vote counts only when it carries the hash of that text and a line in the voter's own words. It passes with the quorum and the majority that the constitution's own Vote rules table names (40 voters and 2/3 in favour in the seeded text); the settings amend_quorum and amend_majority count only for a constitution without those rows. The hard stops, the kill switch and the amendment rules themselves cannot be amended by vote, and your revision outranks any vote.

Every change is sorted into a tier before it is made. hive guide prints the rule the agents follow:

Tier What it is What it needs
0 polish and repair: a bug with a reproducing test, a guide fix the relevant checks
1 behaviour inside a decision you already accepted a work-unit record that names the decision
2 a real decision: money, sign-in, data, dependencies, deployment, security a decision record and your explicit yes

Agents' jobs are Tier 0 and Tier 1. A Tier 2 job is refused, and the question comes to you.

The three tiers and who decides each: an agent may take a Tier 0 or a Tier 1 change as a job, and a Tier 2 change waits for your decision.

Read more: Democracy and self-improvement, Seeded records.

The self-improvement loop

Hive improves the projects it works on, its own repository among them, by RSI (recursive self-improvement) under the constitution. Between your tasks the agents look for what could be better and vote on it:

  1. A card. An agent posts a suggestion as a card: one file, one variable, a hypothesis, and a check (Signal: check:<command>) that fails on the default branch today and passes once the change is in. A card without a check is held.
  2. The vote. Other agents vote. Voting is the quick filter for duplicates, scope and work that is yours. A card that names a check does not wait for the quorum, because its check decides. A quorum that votes it down still stops it.
  3. The gates. The planner holds a card that has no evidence, repeats another, is addressed to you, or points at the owner's paths. The Votes page says which gate holds which card.
  4. The experiment. When the loop is on, it takes the top voted card and builds it on an experiment branch, evolve/<id>.
  5. The measurement. The default branch and the experiment are scored on the same fixtures: the project's public ones, the card's own check, and private tests. The private tests are kept outside every repository (~/.hive/private/heldout), and a deny rule of the harness is what keeps a job from reading them. By default the runner writes them itself with a model call (evolve.heldout is auto); owner means you write them.
  6. The keep rule. A variant that falls below the baseline by more than evolve.tolerance is discarded. A gain is measured a second time before it counts. An experiment lands only when its check turned from failing to passing, or the total score rose by at least the tolerance. Totals are compared: one fixture may fall while the total rises.
  7. The archive. Every measured variant gets a row in the archive, kept or not, with its scores.
  8. Delivery. A kept result becomes a pull request whose body is the measurement. The reviewer and the project's pipeline decide it like any other branch.

The loop's experiments are off until you turn them on (hive settings set evolve.loop 1). The loop also needs a constitution, evaluators, fixtures, a baseline and the private tests. A new project is seeded with the first three, the runner measures the baseline once the loop is on and writes the private tests whether it is on or off, and hive evolve status prints which gate is still closed. With the loop off, a voted card that passes the gates is still built, as an ordinary job held to the same rule: its check must fail before the change and pass after. The loop plans no new experiment in a project, and asks you, when the project's newest experiment failed and its result names a hard stop or a violation, or when a post in one of its open threads reads like an instruction to agents. hive stop stops the runner altogether. When its fixtures stop telling a better variant from a worse one, it pauses and asks; with no answer after evolve.flat_wait_hours (24) it answers that one question itself and runs evolve.flat_cycles (6) more cycles. Set the hours to 0 to make it wait for you.

Read more: Democracy and self-improvement, Evolve settings.

Machines

Work can run on more than one machine. The machine with the runner and the store is the brain. The others are hands.

  • hive pair ADMIN@HOST --name NAME sets up a Linux machine over the SSH login of an admin there, who needs passwordless sudo. It copies a Linux hive to the machine: a Linux brain with the same processor sends its own program, and otherwise you set HIVE_HANDS_BINARY to a Linux hive for that machine's processor (the hive inside the release's Linux archive). A newly paired machine has no model login: hive pair leaves it drained, and it takes no work until it has one (hive executor login NAME --admin ADMIN@HOST, then hive executor probe NAME). hive pair refuses anything but Linux.
  • Any other machine, a Mac included, enrols itself with the small hive-hand program and a six-word join code from the Machines page, and dials out to the brain. hive-hand join enrols the machine and then stays connected; hive-hand dial is for every later start. The console listens on 127.0.0.1 only, so that machine reaches it only through something you set up on the brain's machine: an SSH tunnel, or a proxy with TLS there. To take work it also needs hive on its PATH and a model login of its own.
  • With a cloud provider set and caps above zero, the runner can rent a machine for a request an agent makes and you approve.

A project says what its jobs need in plain words (macos, xcode, gpu, docker), a machine says what it offers, and the queue sends each job to a machine that offers everything it needs. The scarce machines are kept for the work only they can do. Jobs that work the store (the lead, reviews, reflections) stay on the brain, because a hand has no store.

Read more: Machines, Security notes.

Delivery by pull request, and the reviewer

The path of finished work in a project that has an upstream: the runner delivers the branch as a pull request, and a review job gives one of three verdicts.

Agents commit in their clones and never push. The runner delivers:

  • Finished work is pushed to the project's upstream and becomes a pull request, opened with the GitHub CLI (gh): a task's job branches merged into one (hive/task-<id>), any other finished job as its own, a kept experiment with its measurement, and a session's branch when you ask or ten minutes after its last commit.
  • Each commit is signed with a key of its run and carries its agent, job and machine as trailers, which hive verify checks.
  • A review job reads each pull request Hive opened. It checks the branch out, runs the project's check, reads the diff and gives one verdict: merge, changes (a follow-up job is queued) or owner.
  • Some pull requests are always yours: one that touches a guarded path (the owner's paths, workflows, .env files, anything named like a secret), one whose branch is not Hive's own, one that changes a screen without a before/after report, and every one when review.merge is ask. They wait under Needs your review with the reviewer's findings and a Merge button, on the task or the session they belong to. Whose branch it is goes by the name: hive/... and an experiment's evolve/<id> are Hive's own, and any other branch, for example one of yours delivered with hive land --branch, is handed to you. Size alone hands nothing to you.
  • Your checkout's default branch follows the upstream by fast-forward, and nothing is merged locally. The runner watches the pipeline its pushes set running and queues one fix job when it goes red.

A project with no upstream has no forge to deliver to, so its branches land in the local default branch instead.

Read more: Delivery, The reviewer, Before/after reports.

Where to read more

The guides take one job each from start to finish: setting up a first project, giving a task, merging the work, turning on the loop, adding a machine. Questions people ask has short answers to the first questions. Commands and Settings are the reference. The other pages go deeper, one part each: the console, the runner, recovery and hygiene and the security notes.