Skip to content
Design22 min readUpdated 24 Nov 2026

Cluster

Reaktor Cluster would let Reaktor instances on several machines share one workspace's work. A plan item in Hangar can start a coding agent on whichever Mac, Windows or Linux machine suits it, and that agent can ask for a build or a phone check on another machine. Every run stays tied to its plan item, the exact source it ran on, the resources it held and the evidence it produced.

This page is a design. Today two Macs share Gradle work through ~/dev/tools/remote-dev, a router that copies the checkout to one SSH worker, runs the build there and copies outputs back. Plans, claims and conductor tasks live on one machine. What exists today lists the pieces, and Replacing remote-dev maps each part of the router to its place in this design. The design uses Capabilities to know what each machine can do.

Overview#

The workspace on the owner's Mac holds the plan and conductor, the workspace authority and the artifact store. The authority is a scheduler actor plus one durable allocation actor per run, and every run has a lease and a generation number. Each machine runs a host agent with its capability graph, an admission actor that owns all of its capacity, and runners for Gradle, agents and phones. Host agents connect out over one WebSocket, receive assignments with a lease and a generation, and send results and artifacts back, which are accepted only when their generation is current.WORKSPACE, ON THE OWNER'S MACHangar plan and conductorwhat to do: plan items, tasks, checks and reviewsWorkspace authorityScheduler actor: chooses a machine for each runAllocation actors: one per run, written to its storeevery run holds a lease and a generation numberrefuses results from an older generationArtifact storeoutputs, logs and receipts, addressed by content hasha task to runMACHINES, EACH WITH A HOST AGENTm1-worker · macOScapability graph · admission actor owns all capacityrunners: Gradle, coding agents, phone checksWindows PCcapability graph · admission actor owns all capacityrunners: Gradle, coding agents, phone checksLinux machinecapability graph · admission actor owns all capacityrunners: Gradle, coding agents, phone checksassignment, lease, generationresults, checked by generationHost agents connect out over one WebSocket; no machine opens a port.Design only: today remote-dev shares builds between two Macs.
The workspace decides, each machine's host agent runs and guards its own capacity, and generation numbers keep a stale machine from overwriting newer work.

The design has three parts, each with one job:

  • The workspace authority decides. One per workspace. It chooses a machine for each run, records who owns the run, and accepts or refuses results. Its records are durable, so a restart loses nothing.
  • A host agent runs work on its machine. One per machine: a headless Reaktor process that reports the machine's capabilities, owns all of the machine's capacity, and runs tasks in isolated checkouts made from source snapshots.
  • Hangar and the conductor say what to do. Plans, tasks, checks and reviews stay where they are today. The cluster adds where a task runs and who owns it while it runs.

One rule holds the design together: every run holds a lease with a generation number. A machine that loses its lease stops, a run that is started again gets the next number, and every result carries its number, so a machine that comes back late cannot overwrite newer work.

Try it#

The box below plays an iOS build on two Macs. The m1-worker starts it, loses its connection at 25 seconds and comes back at 70. Leases last 30 seconds and renew every 10. After the worker's lease runs out and a 10-second margin passes, the authority starts generation 2 on the Mac Studio. When the worker comes back and reports its old result, the authority refuses it, because generation 1 is older than generation 2.

  • Choose Without generations to see the same events accepted blindly: both runs finish the task, and whichever reports last replaces the other's result.
  • Change the worker's reconnect() to at(40). It is back before its lease runs out, renews in time and keeps the task, so the Mac Studio never starts and its report is refused.
  • Delete the worker's finish("ios-build") line. Nothing changes for the Mac Studio, which finishes generation 2 normally.
  • Add val linux = host("Linux box") under the other hosts and studio.at(90) { disconnect() } at the end. Once the Mac Studio's lease runs out, generation 3 starts on the Linux box, and the Mac Studio's report at 120 seconds never arrives because it is offline.
val studio = host("Mac Studio")
val worker = host("m1-worker")

worker.at(0) { start("ios-build") }
worker.at(25) { disconnect() }
worker.at(70) { reconnect() }
worker.at(75) { finish("ios-build") }
studio.at(120) { finish("ios-build") }

How it works#

Built from Reaktor parts#

Each part of the cluster is made from pieces Reaktor already has.

PartBuilt fromJob
SchedulerAn ActorNode, one per workspaceChooses machines one decision at a time, so two decisions never take the same capacity
AllocationA PersistentActorNode per run, keyed allocation/<id>Holds one run's state machine, lease and generation; its store orders every change
Host admissionAn ActorNode, one per machineOwns every reservation on its machine: CPU slots, memory, phones, disk budget
RunnersNodes in the host agent, one per kind of workRun a Gradle build, a coding agent or a phone flow in an isolated checkout
ClusterApiA Reaktor service over one SocketLinkCarries enrolment, assignments, capability changes, lease renewals and results
Artifact storeContent-addressed storage at the workspaceKeeps outputs, logs and receipts by hash

The contract is declared like any other Reaktor service:

open class ClusterApi : Service("reaktor.cluster") {
    open val enroll by call<Invitation, HostCredential>(effect = Effect.CredentialWrite)
    open val attach by stream<HostHello, Assignment>()
    open val observe by call<CapabilityChanges, Unit>(idempotency = Idempotency.Keyed)
    open val renew by call<Renewal, Lease>(idempotency = Idempotency.Keyed)
    open val report by call<RunReport, Verdict>(idempotency = Idempotency.Keyed)
}

A host agent calls attach once and receives its assignments as a stream; everything it sends back is a keyed call, so a retry after a lost reply repeats the same request. The contract's fingerprint travels with every call, so a host running an older build is recognised as incompatible before it gets work.

The Reaktor V2 paper describes the same structure in its own terms: machines are places, capabilities constrain placement, and a call between places needs an explicit connection. The design keeps that rule and builds on today's graph, actors and services, without waiting for the paper's full runtime.

Hosts and admission#

Each machine's admission actor is the only thing that reserves capacity on that machine. Every Reaktor process on the machine, every workspace that uses it and, during the move, every remote-dev run asks it first. It holds named pools:

PoolExampleCounted
SlotsTwo Gradle jobs at once on the m1-workerPer job
Memory32 GB installed, agents may use 16In bytes, against the configured and measured amounts
DevicesOne iPhone on USBPer physical device, however many bridges reach it
DiskThe 40 GB budget for remote work in storage-limits.jsonIn bytes

A shared subscription is a pool too. Several machines signed in to the same Claude or Codex plan share one usage limit, so the workspace authority owns that pool and admits runs against it, whatever machine they run on.

Admission says how firmly it enforces each pool. Linux cgroups and Windows job objects can cap memory and CPU for a process tree. macOS has no equivalent, so admission there counts reservations and watches usage, and the pane says so.

Admission never waits while holding part of a reservation. It reserves pools in a fixed order and gives everything back when one pool refuses, then reports the reason as a wait: no free slot, phone in use, quota resets at 14:00. An agent that asks for a build on its own machine gives back the slot it does not need while it waits, so a one-slot machine cannot deadlock against its own child.

A run from start to finish#

A run is an allocation: one attempt at one task on one machine. Its state machine is declared on its PersistentActorNode, so every transition is written through the actor's store before anything acts on it.

StateWhat it meansNext
AdmittingThe scheduler chose a machine and is reserving capacity thereAdmitted, or released if the machine refuses
AdmittedCapacity is reserved and the lease is grantedRunning
RunningThe host reports the run started, and renews the leaseFinishing, Unknown
FinishingThe host is uploading results and artifactsSucceeded, Failed
Succeeded, Failed, CancelledFinal for this generation
UnknownThe lease ran out and the host is silentReconciling
ReconcilingThe scheduler asks the host what happened, or waits for proof that it stoppedA final state, or a new allocation with the next generation

The authority records an assignment before it sends it, and the host journals the assignment before it starts it. A start, cancel or result message that arrives twice returns what was recorded the first time. A crash between recording a start and starting the process is a case the host checks when it comes back; recording the intent does not prove the process ran.

Leases and generations#

A timeline. The m1-worker holds generation 1 of ios-build and renews its 30-second lease every 10 seconds. Its connection drops at 25 seconds; its last renewal was at 20, so the lease ends at 50. After a 10-second margin, at 60 seconds, the authority starts generation 2 on the Mac Studio. The worker reconnects at 70 and reports its generation 1 result at 75, which is refused. The Mac Studio reports generation 2 at 120, which is accepted.seconds0202550607075120m1-workergeneration 1, renewinglast renewalconnection lostlease endsbackgen 1 result: refusedMac Studiogeneration 2gen 2 result: acceptedthe lease plus a 10 s margin has passed: start generation 2 on another machine
The worker's late result carries generation 1, so it cannot overwrite generation 2.

Leases and generations follow Gray and Cheriton's leases and the fencing tokens that Chubby calls sequencers:

  • A lease is time-limited ownership. Each assignment carries a lease, for example 30 seconds renewed every 10. The authority measures the lease on its own clock. The host counts its copy from the moment it sent the renewal, so the host's copy always ends first.
  • A host stops when it cannot renew. It starts no new step, cancels its processes, and later reports what actually stopped.
  • A task that writes moves only after the lease has ended. The authority waits for the lease plus a margin, then starts the task again with the next generation number. Read-only work, such as a check whose result anyone can recompute, may start again sooner when its task says so.
  • Every write carries its generation. Results go to the authority, artifacts to the store, candidate patches to the conductor and plan updates to the plan store, each with the allocation and generation. Every receiver keeps the newest generation it has seen for that task and refuses anything older. A refused result is kept as unaccepted evidence, so its logs can still be read.
  • Outside systems need their own keys. A deploy, a store upload or a message to a person cannot check a generation number. Those effects go through keyed calls whose idempotency key the cluster records, and an outcome that stays unknown goes to the owner's review under the kernel's existing policy.

Generations are the safety net for what leases cannot promise: a host that kept running a process it believed it had stopped, or a message delayed in a queue. Clocks only decide when to stop renewing. Safety comes from the numbers.

FailureWhat happens
A reply to a start is lostThe authority repeats the same keyed request, and the host returns what it journalled. No second run starts.
A host goes silentIts capabilities become unknown and admission there stops. A writing task moves only after its lease ends.
A stale host comes backIts results and artifacts are refused by generation and kept as unaccepted evidence.
The authority restartsIt reloads its allocations and renews or cancels them. It never replays a start blindly.
A plan item's claim expires while its run continuesThe open allocation keeps the item claimed.
A host restartsIt comes back as a new incarnation, reports its journal and any processes that survived, and its reservations are checked again.
An outside write times outThe authority looks the result up by its idempotency key. An unknown outcome goes to review.
A shared quota runs outNew starts against that pool stop, and the wait shows the provider's reset time.
A host is drained or revokedAdmission stops at once. Running work follows the declared cancel policy, and the pane shows what actually stopped.

Placement#

The scheduler places a run in five steps:

  1. Check the task is ready. The plan and the conductor still want it, and its source snapshot exists.
  2. Ask the capability resolver where it can run. The resolver returns the eligible machines with the exact capabilities that matched, and the reason every other machine failed. An unknown requirement never counts as met.
  3. Estimate when it would finish on each machine. The wait in that machine's queue, plus the time to bring the snapshot there, plus how long the same task took on that machine before. A warm checkout on the machine costs almost nothing to bring.
  4. Reserve capacity through the chosen machine's admission actor, which checks the evidence again. If it refuses, the scheduler tries the next machine or reports the wait.
  5. Record the allocation, then send it. A send that times out is reconciled by asking about the same allocation. It never starts a second one.

Hard requirements always win over preferences: a busy Mac with Xcode beats an idle Linux machine for an iOS build, and the run waits for it. Shared things are counted once: memory shared by CPU and GPU, a phone reached through two USB bridges, a VM and the containers on it.

MachineTypical workWhat placement must check
macOSApple builds, desktop agents, checks on attached phonesXcode and other toolchains, signing access, attached devices
WindowsWindows builds and agentsThe Windows runtime and its paths; WSL counts as a separate Linux machine
LinuxHeadless agents, container builds, GPU workArchitecture, drivers and container limits
Kubernetes or a managed container serviceA declared worker image or a bounded jobThe provider's limits for the pod or job
A managed service such as a SQL database or a queueCalls to that serviceA service offers its API; it never runs agents or shell commands
A phone or a browserDevice checks and bounded tasks while it is in the foregroundPermissions and background limits; phones and browsers do not host agents

Source snapshots#

Every run executes an exact source snapshot. A snapshot lists each repository in the workspace with its base commit, the files that differ from that commit by content hash, the lock files and the toolchain versions. bestbuds with the reaktor build it includes is one workspace, so one snapshot covers both, and a single commit hash cannot describe it. remote-dev freeze already captures a checkout's source for later builds, and the snapshot builder grows from it.

A snapshot includes the untracked files a build needs, and leaves out credentials, caches and machine state. The host materialises it as a worktree at the base commits plus the changed files, checks every hash before the run starts, and reports any file name, case, link, executable bit or line ending its file system cannot hold. Paths in a task are relative to the workspace, and each platform's runner translates them.

A coding agent works in a worktree that belongs to its allocation, and returns a candidate patch against its snapshot. The workspace applies it through the conductor's existing review and landing rules. Nothing copies a remote checkout over the owner's working tree. When the candidate changes, checks recorded against its old snapshot no longer count.

Artifacts#

Outputs, logs and receipts go to the workspace's artifact store, addressed by their content hash, with the allocation, generation, snapshot and toolchain that produced them. The store accepts an upload only from the current generation, and transfers resume and skip content the store already has.

Build outputs that Gradle can cache travel through the Gradle build cache, which remote-dev already pilots as an HTTP cache over an SSH tunnel. A host fetches a cached output by its cache key and does not copy a build directory. Deliverables a person or a deploy needs, such as an app bundle, are declared outputs of their build nodes; they reach the owner's checkout only through the authority, which checks the generation and the snapshot before it writes.

A successful exit is evidence about a process. A deploy or a phone install keeps its own verification receipt. Caches are separated by trust domain, retention follows the workspace's storage budgets, and cleanup keeps anything an open or unaccepted run still refers to.

Agents on other machines#

A plan item that needs an agent gets an allocation like any other run. The host agent starts the harness, such as Claude Code or Codex, in a worktree made from the item's snapshot, under the agent's own identity. The agent's reaktor MCP server talks to the workspace's kernel through the host agent's connection, so the kernel stays the workspace's single owner, and the remote machine never holds the owner's credentials.

The agent reads and edits the plan with the same operations it uses today, with base revisions, access scopes and approvals unchanged. Its code comes back as a candidate patch, and its checks run wherever their own requirements place them. A host that loses its connection keeps the agent's logs and its candidate, and it cannot mark plan state while it is cut off.

Live processes never move between machines. An agent's conversation moves only when its harness can resume it on another machine; otherwise the next attempt starts fresh with a short summary of the last one and links to its evidence.

Plans in Hangar#

A plan item, its conductor task and its allocation refer to each other by global references made of the workspace, the plan thread and the item id. The plan keeps its statuses: Todo, Doing, Done and Dropped. A launched agent does not make an item Done. A check completes when its receipt is accepted, and a writing task completes through its review.

Today WorkPlanStore.next picks the next ready item and can take it for the calling agent, and a taken item's PlanLease lasts ten minutes, extended by recorded activity. That expiry suits planning work that someone abandoned. It must not hand away work that is still running on another machine, so the design adds one rule: while an item has an open allocation, its lease cannot expire, and only reconciling the allocation releases it. The same rule covers manual starts and retries.

Items gain requirements and preferences, taken from the agent profile, the kind of task, its build node and explicit constraints: an OS, a toolchain, a device, a trust domain, or a preference for a machine with a warm checkout. Readiness and priority still decide which item runs next. Hangar shows why an item waits: a dependency, no capable machine, a full machine, a quota reset, an approval, or a run whose outcome is unknown.

Joining a machine#

Four identities stay separate:

  1. The machine. Enrolled once and kept across restarts.
  2. The host incarnation. New each time the host agent starts, so a restarted host never continues with its old authority by accident.
  3. The agent. The harness's own identity, whichever machine runs it.
  4. The authority and its epoch. The epoch increases whenever the authority restarts or moves, and allocations issued under an old epoch are reconciled before new ones go out.

A machine joins with an invitation the owner creates for the workspace. The invitation is short-lived and works once; it buys the machine its own credential, kept in the platform's keychain. A cloned disk does not clone an enrolment, and a revoked machine is refused at its next call.

The host agent connects out to the workspace over TLS, through a SocketLink that carries calls and streams over one WebSocket, so no machine needs an open port. A private network such as Tailscale can provide the route between machines; identity and permissions stay with Reaktor. The contract fingerprint decides whether a host's build can talk to this authority, and a host that is too old or too new stays visible with that reason. Each renewal carries the host's capability changes and progress, a gap in sequence numbers asks for a fresh snapshot of its graph, and large files travel through the artifact store.

The Cluster pane#

The Cluster subpane would sit in Hangar's Compute pane at cloud/cluster, next to the proposed Capabilities subpane.

  • Machines and runs. Each machine with its enrolment, connection age, offered and reserved capacity, running allocations, quota waits and drain state, as a graph and as a list.
  • The allocation inspector. Why this machine, which machines were rejected and why, the snapshot it runs, what it reserved, when its lease ends, and which result was accepted. An unknown or stale fact says so. A green connection never stands for a successful task.
  • Links both ways. From a plan item to its runs, machines, snapshots, logs, checks and candidates, and from a machine back to the plan items it serves. An older attempt keeps its generation and evidence when you open it.
  • Operations. Enrol, drain, resume, cancel, revoke and retry are kernel operations with previews and the kernel's usual approvals. Drain stops new starts; revoke also removes trust. Neither starts an uncertain writer somewhere else.

Every wait says what would end it: free a phone, reconnect a machine, install a toolchain, wait for a quota reset, loosen a requirement, settle an unknown outcome, or review a candidate.

Replacing remote-dev#

Each piece of the two-Mac router has a place in the design. The move happens piece by piece, and the router's commands keep working until their replacement has passed the same tests.

remote-dev todayIn the cluster
The worker host named in ~/dev/.remote-dev/config.jsonEnrolled machines, any number, any OS
local-gradle.lock and the queue of tickets in local-gradle.lineThe admission actor on this Mac
worker-gradle.lock, worker-slot-<n>.lock and the job folders slots/job-<n>The admission actor on the worker, with slots as a pool
A mirror kept up to date with git ls-files and rsyncSnapshots, materialised as worktrees and checked by hash
remote-dev freeze and snapshot-buildThe snapshot builder
Receipts in ~/dev/.remote-dev/logsAllocation records and their evidence
Copy-back by artifact family, from taskFamilies in build/dependeasy/remote/hosts.jsonThe Gradle build cache and declared outputs in the artifact store
publications.sqlite3, which stops an older run overwriting a newer fileGeneration and snapshot checks at every write
Abandoned runs marked by remote_retention.py once their router process is goneLeases that end, and reconciliation
execution: Local in hosts.json, which keeps deploys on this MacA requirement, such as this Mac's Wrangler sign-in, that placement checks
Capacity probes with macOS tools such as memory_pressureCapability collectors on every OS
Budgets in storage-limits.jsonThe disk pool in each machine's admission
remote-dev mobile and mobile_worker.py for phones on USBDevice capabilities on the machine the phone is plugged into

What exists today#

  • Plans. WorkPlan, PlanSchedule, PlanLease and WorkPlanStore in reaktor-conductor hold components, tasks, checks and decisions, rank ready work, filter by profile and seat, and keep claims with a ten-minute lease extended by activity. WorkPlanStore applies every write in one process.
  • Conductor. AgentWorkspace.attachPlan gives a plan a seat, submits an agent run and binds its run id. AgentWorkspace.startTask and TaskGraphRuntime drive task attempts through graph-owned actors. All of it runs on one machine.
  • remote-dev. Routes Gradle work between this Mac and one SSH worker by observed capacity, with up to two jobs at once on the worker, a ticket queue for the local Gradle lease, receipts, artifact families, guarded publication, retained snapshots and a separate path for phones on USB. It probes capacity with macOS tools.
  • A build cache pilot. ~/dev/reaktor/plane-machines/reaktor-cluster/tooling/build-cache.gradle points Gradle at an HTTP build cache through an SSH tunnel to the worker.
  • Reaktor parts the design uses. ActorNode and PersistentActorNode with their stores, services with streams and keyed calls, SocketLink, and the capability design.
  • The k3s cluster. A single-node k3s cluster on a GCP VM runs production services. It is a cloud resource in the Compute pane and is not meant for builds or agents.

What the cluster improves#

The left column describes the router as it works now; the middle column lists problems it has actually had.

TodayWhat has gone wrongIn the cluster
Outputs are copied back by artifact familyA worker build published an older library over a newer local one, and a copy-back restored test classes whose sources had been deletedOutputs are addressed by content and published only when their generation and snapshot are current
Each host is guarded by lock files and a ticket queueWrapping ./gradlew in gradle-lease deadlocked every Gradle build on the Mac for fifteen minutesOne admission actor per machine owns every reservation, and nothing else takes locks
The worker keeps a mirror up to date with rsyncA folder that existed only in the mirror made build models stale, and a slot reported compile errors that were not in the sourceEach run materialises its snapshot and checks every hash before it starts
Builds read the working treeDeploys carried other sessions' uncommitted workA run names its snapshot, so a deploy can run from a chosen snapshot
A run counts as abandoned when its router process is goneA killed run left publications pending that a later resume would have written over newer outputsLeases end, generations rise, and a stale run's results are refused
One SSH worker and macOS-only probesNo Windows or Linux machines, and no way to place work by toolchainMachines on any OS, placed by their capabilities
Agents run where the workspace owner runsAgents cannot spread across machinesAgents run on any machine and talk to the one workspace kernel

Limitations#

  • Nothing is built. The router covers two Macs; everything else here is a design.
  • One authority per workspace. While it is down, nothing new starts, and running work continues until its leases end. Failing over to a second authority needs a store with transactions or consensus behind it, and running two authorities over the same files does not provide that.
  • Generations protect only receivers that check them. Every outside effect needs its own idempotency key.
  • Live work does not move. Processes and agent conversations restart elsewhere unless the harness can resume them.
  • Each OS needs its own runner. Process control, path handling, credentials and supported harness versions differ on Windows and Linux.
  • Phones and browsers are limited hosts. They offer device checks and short tasks, and background limits can stop them at any time.
  • Enrolled machines run workspace code. Only the owner's machines, or machines inside the same trust domain, should be enrolled.

Delivery plan#

  1. One admission owner per Mac. Host agents on this Mac and the m1-worker, with admission actors that remote-dev also asks. Gradle runs become allocations with leases and generations, routing behaves as today, and the Cluster subpane shows machines and runs read-only.
  2. Snapshots and artifacts. Snapshots and the artifact store replace the mirror and the copy-back, and the Gradle build cache moves from pilot to default.
  3. Agents on the worker. Plan items start coding agents on the m1-worker, with candidate patches coming back for review.
  4. Windows and Linux. Runners, collectors and snapshot checks for both, tested with the same scenarios on all three systems.
  5. Cloud and devices. Kubernetes jobs and other cloud runners through adapters, and phones as device hosts.
  6. Measured scale. Simulated fleets of 2, 10 and 100 hosts, measuring scheduling delay, admission contention, renewal traffic, transfer volume and recovery time, before any fleet size is promised.

These scenarios have to pass before the first release counts as done:

  • A plan sends two independent tasks to two machines and holds a dependent task until both checks are accepted.
  • Two workspaces and the old router share one Mac without exceeding its budget, and one phone behind two bridges is reserved once.
  • Two machines on one subscription respect one usage limit.
  • Duplicate starts and results, lost replies and an authority restart leave one accepted generation.
  • A cut connection during a writing task leaves an unknown outcome, and the stale result is refused after the task moves.
  • A snapshot change between a build and its review invalidates the old check.
  • Cancelling, draining, revoking and restarting report what actually stopped.

Sources#

Papers and articles:

Systems:

  • Capabilities - What each machine can do, and the resolver placement asks.
  • Actors - ActorNode and PersistentActorNode, which the scheduler, admission and allocations are made of.
  • Service Layer - Contracts, streams, keyed calls and SocketLink.
  • Agents - The conductor, plans and agent runs that the cluster places.
  • Dependeasy - Build nodes and their declared outputs.
  • Reaktor V2 - Places, capability offers and placement in the paper.