How a job runs on your hoard¶
allmyram runs development jobs on machines you already own and aren't using. These four drawings follow one job from your laptop to a sandbox and back, show what keeps it boxed in on each kind of runner, and show how a run ends.
The hoard¶
Every machine joins the same way, with a certificate signed by one root key on your laptop. They talk only over tailcat.
One root key, no control plane. The client talks straight to whichever runner has room. The tracker is two ordinary members of the hoard: a sink that writes everything runners ship, and a UI that runs only while you look.
One job, end to end¶
The source goes out as a git snapshot; the output comes back as frames the client can resume from after a disconnect.
sequenceDiagram
participant C as client
participant R as runner
participant H as warden
participant K as containerd
participant P as gVisor pod
Note over C: snapshot, LFS check
C->>R: send-pack, submit
Note over R: repo, workspace, run ID
R->>H: create run, job
Note over H: cgroup + pod spec
H->>K: CRI
K->>P: start (runsc)
Note over P: service and job share localhost,<br/>in the job's own cgroup:<br/>memory · cpu.idle · pids
P-->>R: CRI log: everything the job printed
R-->>C: attach: frames + offsets
The warden never takes a pod spec from the runner. It receives a
constrained job description and builds the spec itself: the runsc handler,
the job's own cgroup, the egress network, no added capabilities, and one host
mount. If the laptop sleeps, the client reattaches with its offsets, so nothing
prints twice and nothing is lost.
What keeps a job boxed in¶
On both platforms the proxy is a job's only way out, and it allows the public internet only. The mechanism is the same too: a Mac runner keeps a Linux machine of its own and runs the Linux setup inside it.
HTTP(S)_PROXY to the runner's proxy
blocked, shown working in experiment 13
One mechanism, two hosts. A job gets three layers: no route out, a
firewall that admits only the proxy port, and no pod-to-pod switching; the
firewall held even when a job added its own route. On a Mac the same layers
sit inside the runner's VM. A job's containers share a pod, so services
reach each other on localhost on both platforms. The proxy decides on the
resolved address and logs every decision. Every runner checks all of this
when it starts (on a Mac, each time its VM starts) and takes no jobs until
it passes. The evidence is in the spike experiments,
numbers 13, 16 and 17.
A Mac runner¶
A Mac runner keeps one Linux VM of its own, under Lima, and runs the Linux
setup inside it: the same warden, egress rules and gVisor sandboxes, and a
pod network a job's containers share, which Compose jobs need. One VM per
container (apple/container) was the first choice and was ruled out:
those VMs could reach the Mac's own services over IPv6 link-local, and the
only host rule that closed it would have affected every such VM on the Mac,
not just allmyram's (experiment 16).
The runner itself stays on the Mac and runs as its owner, with no root and
no change to the Mac's firewall, and its Lima is its own, apart from any
other on the Mac.
A long-lived VM gathers state and holds memory while idle, so the runner keeps this one cheap to throw away. It boots a pinned Garden Linux image that holds only the operating system layer; the runner's own binaries reach it through a shared directory at every boot, and the VM checks them before anything starts. So an upgrade, or any stop that wasn't a clean shutdown (a crash can leave a just-pulled image's files empty), just recreates the VM from the cached image. The VM stops after five minutes with no runs, which gives all its memory back to the owner.
What a job writes lives on a separate XFS disk that Lima keeps apart from the VM, so recreating the VM keeps it. A running job's workspace is a copy on that disk, owned by the job's user, because gVisor refuses a job that isn't root a directory on the share. Mac runner has the details.
Jobs with services¶
Many test suites need a database or an emulator beside them, and a repo
that needs them usually describes them already in Compose. allmyram reads
those files rather than asking for the same services again in a format of
its own. A job is what docker compose run job COMMAND would start: the
job's service and everything it depends on. allmyram reads Compose with the
library and version nerdctl compose uses, and where Compose tools differ it
does what nerdctl does (Principles).
The client does the reading; the runner and the warden see only the
finished job, so a runner never parses a file from a repo. The
Compose files reference lists what happens to
each field.
One pod, one localhost¶
A job's containers, services and the job's own, share one gVisor pod: one
network namespace, one cgroup, one set of limits. That is what keeps the
sandbox simple, and it costs two things. Two containers can't listen on
the same port, so allmyram refuses services that declare one twice. And
the services share the job's memory and CPUs, so a job with a database
needs --memory for both. Real networking between containers, a pod per
service joined by CNI plugins as nerdctl compose's networks are, is
possible later; nothing here rules it out.
Names still work as in Compose. The warden writes a hosts file for each
run and mounts it at /etc/hosts in every container, as the kubelet does,
mapping every service's name and aliases to the pod's loopback. So
postgres:5432 reaches the Postgres service, and the same Compose file
works under Docker. Every container, services included, goes out through
the runner's proxy, with the pod's own names in NO_PROXY, so a service
can fetch what it needs while starting, and a tool that honours NO_PROXY
reaches another service by name directly.
Waiting for services¶
Compose's depends_on with condition: service_healthy holds a container
back until a service passes its healthcheck. nerdctl compose ignores the
condition: it has no daemon, so nothing stays around to wait. allmyram's
runner already stays with every run, so it waits, as Docker does; that is
allmyram's largest deliberate difference from nerdctl.
The work is split by what each side may do. A healthcheck runs inside the
service's own container, with its image's programs (pg_isready is in the
Postgres image, not the job's), and only something holding containerd's
socket can run a command in another container. So the warden does only
the part it alone can, with two narrow operations: run a service's
declared healthcheck once, in that service's container, and start one more
container of the job. Everything else is the runner's: the timings, the retries, the order, and the record.
The warden's Create starts the containers that wait on nothing; the runner
then checks each awaited service on Docker's timing rules and starts each
container as its dependencies are met, services first and the job's own
container last. Nothing inside the sandbox can start the job's container
early.
The timing follows Docker's rules, including its first check, which comes
one interval after the service starts. A healthcheck that sets only test
gets Docker's 30-second interval, and so delays the job by at least 30
seconds;
setting start_period and a short start_interval lets the job start
soon after a quick service is ready.
The runner answers the client as soon as Create returns, so a run that
waits has an ID, a state and a time limit from the start. While it waits,
it is WaitingForServices, and allmyram status lists the services still
awaited. A service that exits, or keeps failing its check, ends the run
with a detail naming it, its last check's output and the end of its log.
Where a container's writes go¶
A named volume that isn't a pad is per-run storage: the path in the
container's own filesystem, starting with what the image has there, as a
new Docker volume does. That lets a database's data volume stand
unchanged. Those writes must land on disk: a test database or build output
can outgrow what memory can spare, and memory-backed storage would count
against the job's limit. gVisor keeps each container's root filesystem
overlay in a file on the host beside the container's root filesystem, its
default root:self mode, and deletes the file with the container, so the
unprivileged warden never has to remove files a service wrote as its own
user (experiment 30). Linux
runners pin that setting in /etc/containerd/allmyram-runsc.toml; the Mac
VM image runs runsc on its defaults, of which this is one, and its next
build pins it the same way. Nothing caps these files yet: they can use the free space of the
disk holding containerd's root.
One path is the exception. gVisor mounts a memory-backed tmpfs at /tmp
when the image's /tmp is empty and the image declares no VOLUME there,
so what a job writes under /tmp counts against its memory. The job's
container gets HOME=/tmp unless the job sets HOME, so caches written
under HOME are memory too, unless the image's /tmp has files or the
image declares VOLUME /tmp, when they are on disk.
Scratch pads¶
A scratch pad is a named cache directory that a runner keeps between jobs: a
Rust target/, uv's package cache, Go's module cache. A job names the pads it
wants, and where each appears in its main container, with --pad NAME:PATH
and --global-pad NAME:PATH. A repo pad (the default) belongs to one repo, and
keeps its latest version per branch, so a branch starts from its own last
build. A global pad is shared by every repo on that runner, for caches that
are the same across projects. Options after the path are ro, fresh (start
empty) and max=SIZE (a soft maximum).
Each job gets its own clone of the pad's latest version, so any number of jobs can use a pad at once and none sees another's changes. When the job ends, the runner publishes it as the pad's new latest version, except for a cancelled run, a run that failed to start, one whose job's own container never started (as when it ended while it waited for its services), one whose sandbox was lost, or one cut off by a runner restart. Whether the job's container started is what containerd reports to the warden as it stops the run, so a run that ran out of time just as its job was being started publishes exactly when the job really did start. When the warden can't tell (the run's pod was already gone, as after a Stop whose answer was lost, or containerd could not say within 5 seconds), nothing is published, and each writable pad says the runner could not confirm the job's container ran. With two global-pad jobs finishing in turn, the later one wins. A pad that can't be prepared makes the run fail to start, with the reason, and never runs the job cold.
Cloning is cheap only on a copy-on-write filesystem: ZFS, btrfs or XFS with
reflinks. Elsewhere the runner copies each pad in full and warns. Pads may use
the disk down to the smaller of 10% of the filesystem and 40 GiB free (the
runner config pads_free_floor_bytes overrides this). When free space falls
below that, the runner deletes versions, those over their soft maximum
first, then the least recently used.
What the sink sees¶
The sink is the always-on half of the tracker. Each runner sends it a heartbeat every 30 seconds, every job's output, a record of how each run ended, and the log lines from its handling of runs. Proxy decisions stay in the runner's journal. A heartbeat says how much memory and CPU the owner left idle, how much of that jobs used, whether the host was under pressure, and what allmyram itself cost. Together they answer the questions lending a machine raises: is this hurting the owner, and is it worth it?
The sink dials the runners, never the other way round. In tailcat the side that dials runs a client node with its own WireGuard engine, and there are far fewer sinks than runners, so this keeps that cost off every runner.
A runner holds what the sink hasn't confirmed in a small RAM buffer, and spills to disk when the sink is away or falling behind, so a short outage loses nothing and no outage slows a job. Spilled telemetry is capped (64 MiB by default); past the cap the runner drops the oldest and counts what it dropped. The sink interprets nothing: it appends OTLP JSON lines to hourly files, which costs almost no memory. Interpreting them happens only while someone looks, with DuckDB reading the files in place. The tracker's UI isn't built yet; How to collect telemetry with a sink shows the DuckDB views that stand in for it.
How a run ends¶
Every run ends in a state that says what happened. A vanished runner or a preempted job is never reported as passed.
A batch job is Starting, then Running, and ends either Exited (the job finished on its own, or hit its time limit) or Stopped (something ended it from outside). A job whose container waits for a service's health is WaitingForServices in between. A run that has ended also carries a reason, shown on each arrow:
stateDiagram-v2
direction LR
[*] --> Starting
Starting --> Running: pod up
Starting --> WaitingForServices: pod up, services awaited
Starting --> Stopped: StartFailed · Cancelled
WaitingForServices --> Running: job's container started
WaitingForServices --> Stopped: StartFailed · Cancelled · RunnerRestarted · Error
WaitingForServices --> Exited: TimedOut
Running --> Exited: Completed · Error · OOMKilled
Running --> Exited: TimedOut (2 h default)
Running --> Stopped: Cancelled · RunnerRestarted · Preempted
Preempted is designed but not built yet. A runner that vanishes can't record anything, so the client gives up on it after a while without contact, says when it last heard from the runner, and says the run may still be running there, with the command to reattach.
Service jobs are designed but not built yet. A service job will hold a lease for as long as its requester's session is live:
stateDiagram-v2
direction LR
Lease: Lease held, session live
Grace: Grace window, 15 min
Gone: Stopped
[*] --> Lease
Lease --> Grace: session drops
Grace --> Lease: session returns
Grace --> Gone: no return
Lease --> Gone: cancelled by the requester, or preempted
Runners are opportunistic. Jobs take every idle core at idle priority and admit against the memory that's free now; when you need the machine back, the newest jobs are preempted and reported as such. Memory admission and preemption aren't built yet: today a runner takes every job it's sent, each within its own limits. A restarted runner stops any sandbox it has no record of, so nothing runs on without supervision.