Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

drawbar

System-wide Git shim and maintenance toolkit for machines running many concurrent coding agents across linked worktrees.

In a multi-horse harness, the drawbar is the rigid bar every team member pulls through to move the load together. drawbar plays the same role in front of git: concurrent worktrees keep using plain upstream git, GitHub/GitLab, and git-lfs, while shared-state operations serialize cleanly instead of failing with cannot lock ref or auto-GC lock races.

Why

When 10+ coding agents work simultaneously in linked worktrees of a shared clone:

  • Concurrent git fetch --prune calls lose compare-and-swap races on refs/remotes/origin/* (error: cannot lock ref ... is at A but expected B).
  • Unscheduled git gc --auto collides with active worktrees.
  • Shell wrappers add ~7 ms of per-call overhead, slowing down small repositories by 3-4x on git status and rev-parse.
  • Unscoped core.fsmonitor=true spawns background watch daemons on every small repo and churns over build directories like target/.
  • Service daemons (orchestrators, MCP servers, IDE backends) often inherit a PATH with /usr/bin ahead of ~/.local/bin, bypassing user-local shims.

Architecture

  • Compiled dual-mode binary (drawbar / git): invoked via a ~/.local/bin/git symlink, it acts as a sub-millisecond shim; invoked as drawbar, it runs management commands (install, uninstall, build-git, gc-daemons, maintenance, status, doctor, and bench).
  • Per-repo lease (flock): serializes shared-state commands (fetch, pull, gc, maintenance, repack, pack-refs, prune, remote prune, remote update, worktree prune) on <common-dir>/drawbar-lease.lock, with configurable timeout (exit 75 and an actionable fuser diagnostic).
  • Scoped fsmonitor: passes -c core.fsmonitor=true -c core.untrackedCache=true only when the real git is >= 2.55 and the repository is above the tracked-file threshold (or opted in via ~/.config/drawbar/config.toml). Never writes core.fsmonitor into shared git config files, so older system git callers keep working.
  • Background maintenance: suppresses mid-swarm auto-GC (-c gc.auto=0) and runs git maintenance run --auto on a user timer under the same per-repo lease.
  • Files ref backend guard: sets init.defaultRefFormat=files so linked worktrees avoid cross-worktree reftable stack-lock errors.

Where to go next

Installing

On Linux or macOS, deploy/install.sh installs the latest GitHub release:

curl -fsSLO https://raw.githubusercontent.com/OttoOps/drawbar/main/deploy/install.sh
bash install.sh             # latest release; add --timers on Linux for the maintenance timers
bash install.sh --uninstall # runs drawbar uninstall

The script downloads drawbar-<version>-<target>.tar.gz and SHA256SUMS, stops before it changes anything when the archive’s checksum does not match, and checks the build attestation with gh attestation verify when gh is signed in. It then runs drawbar install from the unpacked archive and passes it the --force, --adopt-legacy, --timers and --drawbard flags you gave the script. Linux gets the static musl build. --version vX.Y.Z picks a release, --target picks a build, and --archive <file> --sums <SHA256SUMS> installs an archive already on disk. DRAWBAR_RELEASES_URL replaces the GitHub release URL, as an https URL or a plain http one on 127.0.0.1 or localhost.

drawbar install copies the running binary to ~/.local/opt/drawbar/drawbar and links ~/.local/bin/drawbar and ~/.local/bin/git to that copy, so every shell or service with ~/.local/bin ahead of /usr/bin on its PATH runs git through the shim:

$ ./target/release/drawbar install
drawbar: installed /home/acme/.local/opt/drawbar/drawbar
drawbar: linked /home/acme/.local/bin/git
drawbar: linked /home/acme/.local/bin/drawbar
drawbar: set init.defaultRefFormat=files in /home/acme/.gitconfig

The copy goes through a temporary file and a rename, and each link is a new symlink renamed over the old path, so a git call that runs during install gets either the old file or the shim. Running install again replaces the copy and leaves the links alone, which is how you upgrade after a rebuild.

Install checks everything before it changes anything. It refuses, and changes nothing, when ~/.local/bin/git or ~/.local/bin/drawbar holds something drawbar did not make, unless you pass one of these:

FlagWhat it replaces
--adopt-legacyA ~/.local/bin/git symlink that resolves to the agent-git wrapper at ~/.local/opt/agent-git/git, which must still exist.
--forceAny file or symlink. Install never replaces a directory.

Install hard-links the entry it replaces into ~/.local/opt/drawbar/displaced/ before it swaps in its own link, and uninstall moves that entry back. When the replaced entry is a symlink whose target no longer exists, uninstall deletes it instead, so it never leaves a dangling link.

When git’s global config file leaves init.defaultRefFormat unset, counting any [include] files, install appends this block to it and records that it did in ~/.local/opt/drawbar/gitconfig.marker:

[init]
	defaultRefFormat = files

The file is the one git config --global writes to: GIT_CONFIG_GLOBAL when it is set, else ~/.gitconfig, else $XDG_CONFIG_HOME/git/config when only that file exists. A value you set yourself, files or any other, stays as it is. Install never sets worktree.useRelativePaths, because git older than 2.48 cannot read worktrees created with relative paths.

drawbar uninstall removes both links, puts back what install replaced, strips the block install appended so the config file returns byte for byte, and deletes ~/.local/opt/drawbar. When you have edited the config file and the block is no longer at its end, uninstall runs git config --unset init.defaultRefFormat '^files$' instead, which removes the value only while it is still files and keeps your other settings. It leaves alone a ~/.local/bin entry that no longer points at drawbar. Run hash -r in open shells afterwards, or bash keeps trying the cached ~/.local/bin/git path.

drawbar install --timers also installs the systemd user units described in Scheduled maintenance, and --drawbard the drawbard.service unit described in Running drawbard. Uninstall stops and removes them, along with drawbard’s socket directory. Both are Linux only.

Both commands exit 0 on success, 1 when they refuse or a step fails, and 2 for a bad argument. See ADR 0008.

Configuration

drawbar reads an optional TOML file at $XDG_CONFIG_HOME/drawbar/config.toml, or ~/.config/drawbar/config.toml when XDG_CONFIG_HOME is unset or relative. Every key is optional, and these are the defaults:

[fsmonitor]
mode = "auto"              # "auto", "always" or "never"
min_tracked_files = 3000   # index entries at which "auto" turns fsmonitor on
include = []               # repository paths that always get fsmonitor
exclude = []               # repository paths that never get it

[lease]
timeout_secs = 120         # how long fetch, gc and the like wait for the lease
suppress_auto_gc = true    # run agent calls with -c gc.auto=0

[drawbard]
coalesce_ttl_secs = 0      # seconds a successful fetch also answers later equivalent fetches

Paths in include and exclude are absolute or start with ~/.

coalesce_ttl_secs is read by drawbar daemon when it starts, so restart drawbard after you change it (systemctl --user restart drawbard.service; see Running drawbard). At 0, only fetches still running are shared. See ADR 0014.

A missing file means the defaults. When the file is unreadable, is not a regular file such as a FIFO or a directory, is not valid TOML, or holds an unknown key or a bad value, the loader ignores the whole file, returns the defaults, and prints one drawbar: ignoring ... line on stderr that names the file and the problem. The shim reads the file on every call. See ADR 0003.

Which repositories get fsmonitor

The shim puts -c core.fsmonitor=true -c core.untrackedCache=true in front of your arguments when all of these hold, checked in this order:

  1. mode is not "never", the real git is 2.55 or newer, --bare is not given, and you did not set core.fsmonitor yourself with -c, --config-env, GIT_CONFIG_PARAMETERS or GIT_CONFIG_KEY_<n>.
  2. The shim finds the repository and its index has a valid header. It walks up from the working directory, after any -C, to .git, follows a .git file’s gitdir: for a linked worktree, and honors --git-dir, --work-tree, GIT_DIR, GIT_WORK_TREE and GIT_INDEX_FILE. Outside a repository, or with a missing, unreadable or malformed index, git runs without the flags.
  3. No exclude entry covers the repository. Exclude wins over include.
  4. An include entry covers it, mode is "always", or the index holds at least min_tracked_files entries.

An entry covers a repository whose working tree is that path or lies below it, compared component by component without resolving symlinks, so write entries the way pwd -P prints them. An entry that covers a repository’s main working tree also covers its linked worktrees.

The check spawns nothing and reads 12 bytes of the index. On one workstation, in a release build, it took about 10 µs in a standard repository and 26 µs in a linked worktree. ADR 0004 has the details. The flags override a repository’s own core.fsmonitor and core.untrackedCache, so list a repository that uses an fsmonitor hook such as Watchman in exclude.

Per-repo lease

fetch, pull, gc, maintenance, repack, pack-refs, prune, remote prune, remote update and worktree prune take an exclusive flock on <common-dir>/drawbar-lease.lock before git runs and hold it until git exits, so linked worktrees of one clone take turns updating shared refs and packs. The shim finds the common dir with git rev-parse --git-common-dir, passing along the caller’s -C, -c, --git-dir, --work-tree, --bare and --config-env, and resolves a relative answer against the directory the caller’s -C flags lead to. A leased git also runs with gc.autoDetach and maintenance.autoDetach off, so the housekeeping it starts finishes before the lease is released. Every other command runs with no lock and no extra process.

A command waits for the lease for DRAWBAR_LEASE_WAIT seconds, else AGENT_GIT_LEASE_WAIT, else lease.timeout_secs from the config, else 120. When the wait runs out, drawbar exits 75 and prints one line naming the lock file and the fuser -v command that shows who holds it.

When git cannot name a common dir, for example outside a repository, the command runs unleased and git reports its own error. When the lock file exists but this user cannot read it, drawbar exits 75 without running git. The lock file is close-on-exec, so git and anything git starts never hold it, and the kernel releases it whenever the shim exits. When the shim takes the lease it sets the lock file’s modification time to now, which is how drawbar doctor tells how long the lease has been held. A user who cannot write the file leaves the time as it was.

While a leased git runs, the shim waits on it and forwards SIGTERM, SIGINT, SIGHUP and SIGQUIT to it. Once git exits, the shim exits with git’s status, or dies of the same signal git died of. See ADR 0005.

Fetches through drawbard

When drawbard (Running drawbard) listens on $XDG_RUNTIME_DIR/drawbar/drawbard.sock, a leased git fetch asks it to run the fetch and holds no lease while it waits. The daemon runs one real fetch, under this lease, for all the fetches in flight that would start the same git with the same arguments, environment and umask in the same directory, and each caller prints that fetch’s output and exits with its status. A fetch with its own refspec, GIT_SSH_COMMAND or credential variables differs from the others, so it gets a fetch of its own and waits its turn for the lease. A fetch with --append, --depth, --deepen, --shallow-since, --shallow-exclude or --unshallow would do something different the second time, and the daemon cannot pass on the refspecs a --stdin fetch reads, so the shim never sends those to the daemon. The shim sends the lease wait it resolved with the request, so the daemon waits as long as the shim would have. Git sees the caller’s environment as it is, except for PWD, OLDPWD, SHLVL and _, which the daemon leaves out of every git it starts and out of the comparison.

The shim runs its own fetch under the lease, as above, when the socket is missing or not private to this user, the daemon refuses the fetch, the whole answer does not arrive within the lease wait plus 10 minutes, or the working directory’s path names a different directory by the time it does. The daemon refuses a request whose path no longer names the caller’s directory, and one whose path passes through a directory another user owns or can write to without the sticky bit, since that user could put another repository there before git starts. A shim that asked the daemon and got no answer it can use finds its lease again before its own fetch, since the repository it selects may have changed while it waited. A fetch the daemon runs has no terminal, so git cannot prompt there for a password or passphrase, though an askpass program still runs. Interrupting the shim does not stop a fetch the daemon has started, and a daemon killed with SIGKILL releases the lease while its fetch may still be writing refs. See ADR 0014, ADR 0015 and ADR 0016.

Running drawbard

drawbard is the optional daemon that runs one git fetch for every equivalent fetch in flight, so a swarm of agents fetching the same clone makes one network fetch where each would otherwise take its turn under the lease. Per-repo lease says which fetches it shares and when the shim fetches on its own instead. Every fetch works without it: when drawbard is not running, or cannot answer, each fetch takes the lease as it would with no daemon.

As a systemd user service

On Linux, drawbar install --drawbard writes drawbard.service to the systemd user unit directory, $XDG_CONFIG_HOME/systemd/user or ~/.config/systemd/user, enables it, and restarts it:

$ drawbar install --drawbard
drawbar: installed /home/acme/.local/opt/drawbar/drawbar
...
drawbar: wrote /home/acme/.config/systemd/user/drawbard.service
drawbar: enabled and started drawbard.service

deploy/install.sh --drawbard passes the flag on. The unit runs %h/.local/bin/drawbar daemon with XDG_RUNTIME_DIR=%t, ~/.local/bin first on PATH, and LimitNOFILE=1048576, starts with the user manager (WantedBy=default.target), and restarts two seconds after it fails. drawbard reads drawbard.coalesce_ttl_secs from the config file when it starts, so restart it after you change that setting:

$ systemctl --user restart drawbard.service

The service listens on $XDG_RUNTIME_DIR/drawbar/drawbard.sock. drawbard creates $XDG_RUNTIME_DIR/drawbar with mode 0700 when it starts, takes the drawbard.lock file there so a second daemon cannot take over the socket, and binds the socket with mode 0600. A shell or service whose XDG_RUNTIME_DIR is unset, or names another directory, does not find the socket, and its fetches take the lease. On a desktop session, XDG_RUNTIME_DIR is /run/user/<uid> both in your shells and in the user manager.

drawbar install without --drawbard leaves the unit file as it is. When drawbar wrote it, install runs systemctl --user try-restart drawbard.service, so a running drawbard switches to the copy just installed. An older drawbard speaks an older protocol and refuses every fetch, so until it restarts each fetch takes the lease, and drawbar doctor says to restart it.

Stopping

systemctl --user stop drawbard.service sends SIGTERM to the daemon alone (KillMode=mixed). drawbard removes its socket at once, so new fetches take the lease, and exits once the fetches it is running finish and their callers have their answers. No fetch fails because the service stopped. A fetch still running after TimeoutStopSec=10min is killed with the daemon, and each caller waiting on it runs its own fetch under the lease. systemd’s default, KillMode=control-group, would send SIGTERM to those fetches too, and every caller would fail with them.

Uninstalling

drawbar uninstall runs systemctl --user disable --now drawbard.service, which waits as a stop does, then removes the unit file. It then removes $XDG_RUNTIME_DIR/drawbar, with the lock file and any socket left in it, once it holds the lock itself, creating the lock file when it is missing, so a daemon that starts meanwhile cannot bind a socket there. It leaves the directory when a drawbard still holds the lock, when it holds other files, or when another user could reach it or put files in it, by the same checks the shim makes before it uses the socket. When systemctl fails, uninstall keeps the unit file, the ~/.local/bin links and the binary the service runs, reports the error, and removes them on the next uninstall, as it does for the timers.

Install refuses, and changes nothing, when a drawbard.service that drawbar did not write is already in the unit directory, the systemd user manager is not reachable, or systemd loads drawbard.service from another file, such as one in ~/.config/systemd/user.control, which systemd searches first. Uninstall leaves such a unit running. Customize the unit with systemctl --user edit drawbard.service drop-ins, which install and uninstall leave alone. See ADR 0017.

Without systemd

The unit is Linux-only, like the timers, and install.sh refuses --drawbard on macOS. Elsewhere, run drawbar daemon yourself, with the same XDG_RUNTIME_DIR your git callers have, from something that gives it no terminal, since a fetch it runs could prompt there. drawbard starts a session of its own when it can, and refuses to start when it cannot and a terminal is still attached. On Linux without a user manager:

$ setsid drawbar daemon < /dev/null > /dev/null 2>&1

macOS sets no XDG_RUNTIME_DIR. To use drawbard there, set it to a directory that belongs to you and that no other user can write to, in your shell profile and in a launchd agent that runs drawbar daemon. SIGTERM or SIGINT stops the daemon as systemctl stop does. Send the signal to the daemon’s own PID: a signal to its process group also reaches the fetches it runs, and they die with it.

Checking it

drawbar status reports the socket, whether drawbard answers and in which protocol, and whether the unit is installed. drawbar doctor reports the same as its drawbard.daemon check: it warns when the unit is installed but nothing listens, when a socket is there but nothing answers, when the shim will not use the socket because it is not private to you, and when the daemon speaks another protocol. Both ask the daemon only for its protocol, with a request every daemon refuses before it runs anything. See Status and doctor.

Building Git

The shim turns on fsmonitor only for a real git of 2.55 or newer. drawbar build-git builds one from the official source tarball into ~/.local/opt/git-<version>, where the shim looks for real git before it falls back to the system one:

$ drawbar build-git
drawbar: built /home/acme/.local/opt/git-2.56.1
OptionDefaultMeaning
--version <v>2.56.1Download git-<v>.tar.xz from kernel.org and build it.
--tarball <path>Build a local git-<v>.tar.xz or git-<v>.tar.gz instead. The version comes from the file name.
--sha256 <digest>pinnedThe tarball’s expected SHA-256. Required for a version drawbar has no pinned digest for.
-j, --jobs <n>4The make -j job count.
--min-free-ram <size>4GRefuse to start when /proc/meminfo shows less available memory than this. Sizes take K, M, G or T. 0 skips the check.

drawbar pins the SHA-256 of the Git 2.56.0 and 2.56.1 tarballs from kernel.org’s signed sha256sums.asc, copies the tarball into a scratch directory, hashes the copy, and unpacks that same copy only when the digest matches. make builds with NO_TCLTK and NO_GETTEXT set, so the build needs a C compiler and the zlib, OpenSSL and libcurl headers, and neither Tcl nor msgfmt. make install writes to a staging directory first, and drawbar moves the result into place only when libexec/git-core holds git-remote-https and git-fsmonitor--daemon, so a git that cannot fetch over HTTPS never lands where the shim would pick it up. A host without the libcurl headers stops earlier, in make, with the compiler’s error.

It refuses to overwrite an existing ~/.local/opt/git-<version>, so remove that directory to rebuild, and DRAWBAR_MAKE names a make program other than make. It exits 0 when Git was built and installed, 1 when the build was refused or failed, and 2 for a bad argument, and every refusal prints one drawbar: line. See ADR 0007.

Stopping fsmonitor daemons

drawbar gc-daemons lists your running git fsmonitor--daemon processes, one line each, and stops the ones drawbar no longer wants running:

$ drawbar gc-daemons
4102 kept /home/acme/src/monorepo: left running
4177 below-threshold /home/acme/src/widgets (212 tracked files, under 3000): stopped
4230 excluded /home/acme/src/vendored (fsmonitor.exclude): stopped
4391 orphaned /home/acme/wt/old-branch (working tree is gone): stopped with SIGTERM

Each line gives the PID, the verdict, the working tree, and what happened.

VerdictMeaningStopped
orphanedIts git dir or working tree is gone, or the working tree path now holds another directory, as after a move.Yes
excludedAn exclude entry covers the repository, or mode is "never".Yes
below-thresholdmode is "auto", no include entry covers the repository, and its index holds fewer than min_tracked_files entries.Yes
keptThe rules in Which repositories get fsmonitor still qualify the repository, or its index cannot be read.No
unknowndrawbar cannot tell which repository the daemon serves, as when a daemon in a deeply nested repository has lost its working tree.No

The verdicts come from the rules the shim uses, so the two never disagree about a repository. drawbar stops a daemon whose repository still exists with git fsmonitor--daemon stop, run by the resolved real git. It sends an orphaned daemon, or one still running five seconds after that, SIGTERM by its exact PID, through a pidfd, only after it checks that the PID still has the same owner, command line, and start time. It never matches processes by name with pkill -f, and it only looks at your own processes.

  • --dry-run, or -n, lists the daemons and stops nothing.
  • Paths after the options limit the run to daemons whose repository lies at or below one of them, as in drawbar gc-daemons ~/src/acme.

It exits 0 when nothing failed, 1 when a daemon could not be stopped, /proc could not be read, or the config file was ignored, and 2 for a bad argument. While the config file is ignored it stops nothing, so a typo cannot stop the daemons your include list keeps. It reads Linux /proc and needs Linux 5.3 or newer; on other platforms it prints that it is not supported.

A repository that turns core.fsmonitor on in its own git config gets its daemon back the next time git runs there, so list it in include if you want it kept. ADR 0006 says how drawbar finds each daemon’s repository.

Scheduled maintenance

drawbar maintenance runs git maintenance run --auto in every repository in git’s maintenance.repo registry, the list git maintenance register adds to. Each run goes through the shim, so it takes the repository’s lease and waits its turn behind agents fetching in the same clone:

$ git -C ~/src/widgets maintenance register
$ drawbar maintenance
drawbar: maintained /home/acme/src/widgets
drawbar: skipped /home/acme/src/old-clone: not a directory

Paths after the command replace the registry, as in drawbar maintenance ~/src/widgets. A registered path that is not a directory is skipped. A repository whose run fails, including one that could not get the lease within the wait, is reported, and the rest still run. The command exits 0 when nothing failed, 1 when a run failed or the registry could not be read, and 2 for a bad argument.

Plain git maintenance start never takes the lease, because git’s own scheduler runs git for-each-repo, which starts git from its exec path and skips the shim.

drawbar install --timers writes four systemd user units to $XDG_CONFIG_HOME/systemd/user, or to ~/.config/systemd/user when XDG_CONFIG_HOME is unset, and enables both timers:

ServiceRunsTimerSchedule
drawbar-maintenance.servicedrawbar maintenancedrawbar-maintenance.timerHourly, up to 10 minutes late
drawbar-gc-daemons.servicedrawbar gc-daemonsdrawbar-gc-daemons.timerDaily, up to 30 minutes late

Both services set LimitNOFILE=1048576 and put %h/.local/bin first on PATH. Both timers are persistent, so a run missed while the machine was off happens at the next boot. The templates are in deploy/ and are built into the binary, so running install --timers again after an upgrade rewrites them to match. Change them with systemctl --user edit <unit> drop-ins, which install leaves alone.

Install refuses, and changes nothing, when a file at one of those names was not written by drawbar, the systemd user manager is not reachable, or systemctl --user show -p FragmentPath says systemd loads one of the units from another file, such as one in ~/.config/systemd/user.control. drawbar uninstall disables the timers before it removes the unit files, and leaves running a timer systemd loads from another file. When systemctl fails, it keeps the files, along with the links and the binary their services run, reports the error, and removes them all on the next uninstall. DRAWBAR_SYSTEMCTL names a systemctl other than the one on PATH. See ADR 0009.

Status and doctor

Checking an install

drawbar status reports how drawbar is set up on this machine, and changes nothing while it does:

$ drawbar status
drawbar 0.1.0

install
  /home/acme/.local/bin/git: drawbar, links to /home/acme/.local/opt/drawbar/drawbar
  /home/acme/.local/bin/drawbar: drawbar, links to /home/acme/.local/opt/drawbar/drawbar
  /home/acme/.local/opt/drawbar/drawbar: present

real git
  /home/acme/.local/opt/git-2.56.1/bin/git: git 2.56.1

resolve cache
  /home/acme/.cache/drawbar/real-git.cache: fresh: /home/acme/.local/opt/git-2.56.1/bin/git (git 2.56.1)

config
  /home/acme/.config/drawbar/config.toml: absent, using the defaults
  fsmonitor.mode = "auto"
  fsmonitor.min_tracked_files = 3000
  fsmonitor.include = []
  fsmonitor.exclude = []
  lease.timeout_secs = 120
  lease.suppress_auto_gc = true
  drawbard.coalesce_ttl_secs = 0

fsmonitor
  /home/acme/src/widgets, 48210 tracked files
  gets core.fsmonitor: its tracked files reach fsmonitor.min_tracked_files

drawbard
  /run/user/1000/drawbar/drawbard.sock: running, protocol 2
  /home/acme/.config/systemd/user/drawbard.service: installed

Each section of the report answers one question:

  • install says whether ~/.local/bin/git and ~/.local/bin/drawbar run drawbar, and whether the installed copy is in place.
  • real git names the git the shim runs and its version, found the way the shim finds it, or says why no git resolves.
  • resolve cache says whether the next git call can use the cached real-git path (fresh) or has to probe the candidates again (missing or stale).
  • config names the file it read and lists the settings in force. When the shim would ignore the file, the report gives the reason and lists the defaults in its place.
  • environment lists the variables that change the shim, such as DRAWBAR_REAL_GIT and DRAWBAR_LEASE_WAIT, and appears only when one is set.
  • fsmonitor names the repository in the current directory and its tracked-file count, and says whether the shim adds core.fsmonitor there and why.
  • drawbard names drawbard’s socket and says whether a daemon answers there and in which protocol, and whether drawbard.service is installed, is a file drawbar did not write, or cannot be read. See Running drawbard.

drawbar status --json prints the same report as one JSON object, for scripts and monitoring. Status takes the real git from a fresh resolve cache, the way the shim does, and otherwise runs each candidate git with --version. It never writes the resolve cache or any other file. It asks a listening drawbard only for its protocol, with a request every daemon refuses before it runs anything, and waits at most 2 seconds for the answer. It exits 0 once the report is printed and 2 for a bad argument.

Health checks

drawbar doctor checks that the shim is installed and runs ahead of the system git, and that nothing in the git config or your repositories breaks it. It prints one line per check, and under each problem one line that fixes it:

$ drawbar doctor
drawbar doctor 0.1.0

ok    install.binary: /home/acme/.local/opt/drawbar/drawbar is a drawbar binary
ok    install.git: /home/acme/.local/bin/git runs drawbar
ok    install.drawbar: /home/acme/.local/bin/drawbar runs drawbar
ok    install.real-git: the shim runs /home/acme/.local/opt/git-2.56.1/bin/git (git 2.56.1)
ok    install.config: /home/acme/.config/drawbar/config.toml is absent, so the defaults apply
fail  path.order: /usr/bin comes before /home/acme/.local/bin on PATH, so git runs /usr/bin/git and skips the shim
      fix: put ~/.local/bin first on PATH: add `export PATH="$HOME/.local/bin:$PATH"` to your shell profile and start a new shell
fail  path.git: git on PATH is /usr/bin/git, not the drawbar shim
      fix: put /home/acme/.local/bin ahead of /usr/bin on PATH
ok    gitconfig.ref-format: init.defaultRefFormat is files
ok    gitconfig.fsmonitor: the global and system git config do not turn core.fsmonitor on
ok    repos.relative-worktrees: none of 3 configured repositories enables it
ok    repos.lease-lock: the lease is free in 3 of 3 configured repositories
warn  systemd.path: acme-orchestrator.service gets PATH from the user manager without /home/acme/.local/bin, so git run by name in it skips the shim
      fix: run `systemctl --user edit acme-orchestrator.service`, add `Environment="PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin"` under [Service], then run `systemctl --user restart acme-orchestrator.service`
ok    daemons.fsmonitor: 4 git fsmonitor--daemon processes use 38.2 MiB RSS and 61004 inotify watches: 4 watching a repository that qualifies
ok    daemons.inotify: 63117 of 524288 inotify watches (fs.inotify.max_user_watches) in use, 61004 of them by fsmonitor daemons
warn  drawbard.daemon: drawbard on /run/user/1000/drawbar/drawbard.sock speaks protocol 1, not this drawbar's 2, so it refuses every fetch and each takes the lease
      fix: restart drawbard so it runs this drawbar: run `systemctl --user restart drawbard.service`

unhealthy: 2 failed, 2 warned
CheckLevelProblem it reports
install.binary, install.git, install.drawbarfail, or warnThe installed copy or a ~/.local/bin entry is missing, is not drawbar, or is a drawbar binary that install did not place, which is a warning.
install.real-gitfailNo real git resolves, so every git call exits 78. When the candidates fail because git cannot read its config, doctor shows git’s error, which names the file.
install.configfailThe shim ignores the config file and uses the defaults.
path.orderfail~/.local/bin is missing from PATH, or comes after /usr/bin.
path.gitfailThe first git on PATH is not the drawbar shim.
gitconfig.ref-formatfail, or warninit.defaultRefFormat is not files, or GIT_DEFAULT_REF_FORMAT names another format. An unset init.defaultRefFormat is a warning.
gitconfig.readfailGit cannot read its global or system config, and names the file in its error.
gitconfig.fsmonitorwarnThe global or system git config, or a file it includes, turns core.fsmonitor on for every repository.
repos.relative-worktreeswarnA configured repository sets extensions.relativeWorktrees to any value, and a git older than 2.48 is installed as the git in a PATH directory, as /usr/bin/git, or as the real git.
repos.lease-lockfail, or warnThis user cannot open a repository’s drawbar-lease.lock, so every leased git there exits 75. A process that has held the lease for at least the lease wait is a warning.
systemd.pathwarnA systemd user service that runs git has no ~/.local/bin on the PATH it runs with, or has /usr/bin ahead of it, or runs a git other than the shim by its path, so its git skips the shim. Linux only.
daemons.fsmonitorwarnA git fsmonitor--daemon is orphaned, excluded, or below the tracked-file threshold, so drawbar gc-daemons would stop it. The message counts the daemons, their total RSS and their inotify watches. Linux only.
daemons.inotifywarnThe user’s inotify watches reach 90% of fs.inotify.max_user_watches. Linux only.
drawbard.daemonwarndrawbard speaks another protocol, so it refuses every fetch; a socket is there but nothing answers; something that is not a socket is at the socket path; the shim will not use the socket because another user could reach or replace it; a drawbard.service, drawbar’s or not, is there but nothing listens, or XDG_RUNTIME_DIR is not set; or the unit file cannot be read. Before it suggests systemctl --user restart drawbard.service, it checks that systemd loads drawbar’s unit file with no drop-ins. When systemd has no file loaded for the unit, or loads another file, the fix says to run systemctl --user daemon-reload and doctor again, and to move that other file only if it still wins. With drop-ins, it says to check systemctl --user cat drawbard.service first. drawbard is optional, so no daemon and no unit passes.

The configured repositories are the maintenance.repo registry that drawbar maintenance runs on, each fsmonitor.include entry that is itself a repository, and the repository in the current directory. Doctor finds each one’s common git directory without running git, so it still reads a repository that an old git cannot open. Linked worktrees of one clone share a common git directory, so they count once.

To tell whether a lease is held, doctor tries a shared lock without waiting and releases it at once. On Linux it finds the holder in /proc/locks, and times the hold from the modification time the shim sets when it takes the lease. When that time is older than the holder’s process, read from /proc/<pid>/stat, the holder could not set it, and doctor reports the hold without timing it. On other platforms it reports a held lease without timing it. Doctor compares the hold with the lease wait the shim uses: DRAWBAR_LEASE_WAIT, else AGENT_GIT_LEASE_WAIT, else lease.timeout_secs.

The systemd.path check inspects drawbar’s own service units, when installed, and each active systemd user service whose command line or environment points at git: an ExecStartPre, ExecStart or ExecStartPost word named git or git-<something>, or a GIT_* variable in its Environment= or its EnvironmentFiles. It leaves the other services out, since most never run git and the user manager’s default PATH would flag every one of them. A service’s effective PATH is the last one its EnvironmentFiles set, else its own Environment=PATH=, else the user manager’s from systemctl --user show-environment, else systemd’s default. The fix names the place that sets it. A service whose Exec line runs a git other than the shim by its absolute path, such as ExecStart=/usr/bin/git fetch, warns too, whatever its PATH. A wildcard EnvironmentFile= is read as a literal file name. Doctor reads all of this with systemctl --user, or the program DRAWBAR_SYSTEMCTL names, and skips the check when systemctl is missing or no user manager answers.

The daemons checks find each git fsmonitor--daemon the way drawbar gc-daemons does and give it the same verdict, without stopping anything. A daemon is watching when its repository still qualifies, orphaned when its repository is gone, and unneeded when it is excluded or below the tracked-file threshold. RSS is each daemon’s VmRSS. The inotify count is the sum of the inotify wd: lines in the fdinfo of every inotify descriptor the user’s processes hold, the same per-user total the kernel holds against fs.inotify.max_user_watches. The count is an estimate: an inotify instance that two descriptors share counts twice. Doctor reads /proc, or the tree DRAWBAR_PROC names, and skips both checks when it cannot.

Doctor reads the git config the way git does outside a repository, with the real git, and leaves out per-process settings such as GIT_CONFIG_PARAMETERS. It changes nothing. drawbar doctor --json prints the report as one JSON object, with healthy, a count per level, and each check’s id, level, message and fix. The level is ok, skip, warn or fail. A check is skipped when something it needs is missing, such as a real git to read the config with, and another check reports that. Doctor exits 0 when no check warned or failed, 1 when one did, and 2 for a bad argument.

Measuring shim overhead

drawbar bench times git run directly with the real git against git run through the ~/.local/bin/git shim, and reports what the shim adds:

$ drawbar bench --repo ~/src/widgets
drawbar bench 0.1.0

real git  /home/acme/.local/opt/git-2.56.1/bin/git (git 2.56.1)
shim      /home/acme/.local/bin/git
repo      /home/acme/src/widgets
runs      50 of each command each way, after 5 warmup

git --version
  direct    median  0.852 ms  p95  1.143 ms
  shim      median  1.214 ms  p95  1.581 ms
  overhead  median +0.362 ms  p95 +0.438 ms

git status --porcelain
  direct    median 41.302 ms  p95 44.826 ms
  shim      median 41.718 ms  p95 45.407 ms
  overhead  median +0.416 ms  p95 +0.581 ms

Bench runs git --version and git status --porcelain, each through the real git the shim resolves and through the shim, and reports the median and the p95 of each, then the overhead: the shim’s median minus the direct median, and the same for the p95. Both run in the repository with the same environment, so the shim run includes everything the shim does there: resolving the real git, reading the config, the auto-GC guard, and any core.fsmonitor flags. When the shim turns fsmonitor on for a large repository, its git status can beat the direct run, and the overhead is negative.

Each round runs every command both ways and alternates which runs first, so a change in machine load falls on both. Warmup rounds run first and are not counted.

OptionDefaultMeaning
--repo <path>the current directoryWhere git status runs. The report names the repository’s top level.
--iterations <n>50Counted runs of each command each way, from 1 to 10000.
--warmup <n>5Uncounted runs before them, from 0 to 10000.
--jsonPrint one JSON object instead of text.

drawbar bench --json prints the real_git path and version, the shim, the repo, iterations, warmup, and one entry per command in commands, each with direct, shim and overhead times as median_us and p95_us in whole microseconds. The text report shows the same values in milliseconds. Bench exits 0 once the report is printed, 1 when the shim is not installed, no real git resolves, the path is not in a git repository, or a timed git command fails, and 2 for a bad argument.

Exit codes and auto-GC guard

Shim exit status

For unleased commands drawbar replaces itself with the real git through exec, so the caller sees git’s own exit code, or git’s death by signal, exactly as it would without the shim, and signals sent to the shim reach git directly. Leased commands report git’s status the same way, as described above. drawbar exits with a status of its own only when git never starts:

StatusMeaning
75A leased command did not get the lease, because another git command held it for the whole wait or the lock file could not be opened.
78The real git could not be resolved, because DRAWBAR_DEPTH reached 16, DRAWBAR_REAL_GIT or AGENT_GIT_REAL names the shim or a copy of it, or no candidate is a usable git.
126The resolved git exists but could not be executed.
127The resolved git disappeared before it could be executed.

Each of these prints one drawbar: line on stderr that names the cause and the fix. See ADR 0002.

Auto-GC guard

In shim mode drawbar puts -c gc.auto=0 ahead of the caller’s arguments, so the git gc --auto that commands such as fetch, merge and commit start on their own finds no work to do while sibling worktrees are busy. Explicit git gc and git maintenance run without it, and that holds when global flags come first, as in git -C widgets gc. A -c gc.auto=<n> the caller passes still wins, because git keeps the last value it reads.

Set DRAWBAR_GC_AUTO_GUARD=0 to turn the guard off, or any other non-empty value to turn it on. When the variable is unset or empty, lease.suppress_auto_gc in the config decides, and it defaults to true.

Troubleshooting

Start with drawbar doctor. It prints one line per check and, under each problem, one line that fixes it. drawbar status shows the install, the real git, the resolve cache and the config in force. Neither changes anything.

Git runs without the shim

path.order and path.git fail when ~/.local/bin is missing from PATH, comes after /usr/bin, or the first git on PATH is not the shim. Put ~/.local/bin first on PATH: add export PATH="$HOME/.local/bin:$PATH" to your shell profile and start a new shell.

After drawbar uninstall, run hash -r in open shells, or bash keeps trying the cached ~/.local/bin/git path.

A systemd user service that runs git can skip the shim too. systemd.path warns when such a service has no ~/.local/bin on its PATH, has /usr/bin ahead of it, or runs a git other than the shim by its absolute path. The fix names the place that sets the PATH. For a service, it reads:

$ systemctl --user edit <unit>
$ systemctl --user restart <unit>

with Environment="PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin" under [Service] in the drop-in. A service whose Exec line runs git by an absolute path such as /usr/bin/git warns whatever its PATH.

drawbar: ignoring ... on stderr

The config file is unreadable, is not a regular file, is not valid TOML, or holds an unknown key or a bad value. The shim ignores the whole file and uses the defaults, and the line names the file and the problem. install.config fails in drawbar doctor for the same reason. Fix the file named. See Configuration.

While the config file is ignored, drawbar gc-daemons stops nothing, so a typo cannot stop the daemons your include list keeps.

Exit status 75

A leased command did not get the lease. Either another git command held it for the whole wait, or the lock file could not be opened. The line drawbar prints names the lock file and the fuser -v command that shows who holds it.

  • To wait longer, set DRAWBAR_LEASE_WAIT (seconds), or lease.timeout_secs in the config. The default is 120.
  • repos.lease-lock fails when this user cannot open a repository’s drawbar-lease.lock, so every leased git there exits 75. It warns when a process has held the lease for at least the lease wait.

See Per-repo lease.

Exit status 78, 126 or 127

Status 78 means the real git could not be resolved: DRAWBAR_DEPTH reached 16, DRAWBAR_REAL_GIT or AGENT_GIT_REAL names the shim or a copy of it, or no candidate is a usable git. install.real-git fails in drawbar doctor. When the candidates fail because git cannot read its config, doctor shows git’s error, which names the file, and gitconfig.read fails too.

Status 126 means the resolved git exists but could not be executed, and 127 means it disappeared before it could be executed. Each prints one drawbar: line that names the cause and the fix. See Exit codes and auto-GC guard.

drawbar install refuses

Install checks everything first and changes nothing when it refuses.

  • ~/.local/bin/git or ~/.local/bin/drawbar holds something drawbar did not make. Pass --adopt-legacy for a ~/.local/bin/git symlink that resolves to the agent-git wrapper at ~/.local/opt/agent-git/git, which must still exist, or --force for any file or symlink. Install never replaces a directory.
  • With --timers or --drawbard, a file at one of the unit names was not written by drawbar, the systemd user manager is not reachable, or systemd loads one of the units from another file. systemctl --user cat <unit> names that file.

See Installing, Scheduled maintenance and Running drawbard.

Fetches do not go through drawbard

Every fetch still works without drawbard: it takes the lease instead. drawbard.daemon in drawbar doctor says why drawbard is not answering, and drawbar status shows its socket and protocol.

  • Another protocol. The daemon is from an older or newer drawbar, so it refuses every fetch. This happens after an upgrade when drawbard was not restarted. Run systemctl --user restart drawbard.service.
  • Nothing listens. A drawbard.service is there, but no socket is. journalctl --user -u drawbard.service says why the daemon stopped or did not start: another daemon holds drawbard.lock, another user could replace XDG_RUNTIME_DIR or a directory above it, or something that is not a socket is at the socket path.
  • Nothing answers. A socket is there, but no daemon answers on it, as after a daemon was killed with SIGKILL. Restart drawbard, which replaces the socket.
  • Not a socket. Something other than a socket is at $XDG_RUNTIME_DIR/drawbar/drawbard.sock, and drawbard refuses to replace it. Look at what it is, remove it, then restart drawbard.
  • Not private. The shim does not use a socket that another user could reach or replace. The message names the path to fix.
  • No XDG_RUNTIME_DIR. A shell or service without it, such as a cron job or a su session, never looks for drawbard. Set it to the directory systemctl --user show-environment prints.

See Running drawbard.

drawbar build-git refuses

  • ~/.local/opt/git-<version> already exists. Remove that directory to rebuild.
  • /proc/meminfo shows less available memory than --min-free-ram, which defaults to 4G. 0 skips the check.
  • The version has no pinned SHA-256. Pass --sha256 <digest>.
  • The tarball’s digest does not match.
  • The host lacks the libcurl headers. The build stops in make with the compiler’s error, and a build is installed only when libexec/git-core holds git-remote-https and git-fsmonitor--daemon.

See Building Git.

fsmonitor daemons keep running

daemons.fsmonitor warns when a git fsmonitor--daemon is orphaned, excluded, or below the tracked-file threshold. drawbar gc-daemons stops those. A repository that turns core.fsmonitor on in its own git config gets its daemon back the next time git runs there, so list it in include if you want it kept.

gitconfig.fsmonitor warns when the global or system git config, or a file it includes, turns core.fsmonitor on for every repository. A repository that uses an fsmonitor hook such as Watchman belongs in exclude, because the shim’s flags override its own core.fsmonitor and core.untrackedCache.

daemons.inotify warns when the user’s inotify watches reach 90% of fs.inotify.max_user_watches.

See Stopping fsmonitor daemons and Which repositories get fsmonitor.

Ref format and old git

gitconfig.ref-format fails when init.defaultRefFormat is not files, or GIT_DEFAULT_REF_FORMAT names another format, and warns when init.defaultRefFormat is unset. drawbar install sets it to files when it is unset, and never sets worktree.useRelativePaths.

repos.relative-worktrees warns when a configured repository sets extensions.relativeWorktrees and a git older than 2.48 is installed as the git in a PATH directory, as /usr/bin/git, or as the real git. Such a git cannot read worktrees created with relative paths.

Security model

drawbar sits in front of git for every agent and service you run, so a flaw in it runs with your rights. The model below says whose rights those are, what the shim does to avoid running the wrong git, and what each command that changes your machine checks before it does.

Trust boundary

drawbar runs as the user who installed it. It needs no root, installs nothing system-wide, and Phase 1 has no daemon and no socket (ADR 0001). Phase 2 adds drawbard, a per-user daemon on a Unix socket that runs a git fetch for the shim (ADR 0014). A leased git fetch sends it the real git’s path, the working directory with its device and inode, the umask, the arguments, the lease wait and the whole environment, which can hold tokens. The shim sends nothing unless every directory and symlink from the root to $XDG_RUNTIME_DIR belongs to root or this user, any of them another user can write to is sticky, the drawbar directory below it belongs to this user with no group or other access, and the socket is a socket, not a symlink, that belongs to this user. Otherwise it runs its own fetch under the lease. The daemon opens the working directory by its path, so it refuses a request whose path passes through a directory that belongs to another user, or that another user can write to without the sticky bit: no other user can then put their own repository at that path between the daemon’s check and the git it starts there (ADR 0016).

Other processes that run as the same user share that trust boundary. They can already run anything drawbar can, so drawbar treats these inputs as trusted: the environment (DRAWBAR_REAL_GIT, DRAWBAR_LEASE_WAIT, DRAWBAR_MAKE, DRAWBAR_SYSTEMCTL and the other DRAWBAR_* variables), the config file, and everything under ~/.local/opt and ~/.local/bin. The checks below defend against a wrong git being run by accident, a corrupted download, and a half-finished install. They do not defend against another process of the same user.

The crate denies unsafe_code in Cargo.toml. System calls such as flock, kill and waitid come from the safe API of rustix, and signal handling from signal-hook (ADR 0005).

Finding the real git

The shim never searches PATH for git, so a directory an attacker or a mistake puts ahead of /usr/bin cannot choose the binary it runs. It tries a fixed list of candidates in order:

  1. $DRAWBAR_REAL_GIT,
  2. $AGENT_GIT_REAL, the shell prototype’s name for it,
  3. the newest ~/.local/opt/git-2.56.*/bin/git,
  4. the newest ~/.local/opt/git-2.*/bin/git,
  5. /usr/bin/git.

A candidate must be an absolute path to a regular file with an execute bit. The shim then rejects it when any of these holds:

  • it is the running executable, by canonical path or by device and inode,
  • its bytes contain a marker string that every drawbar build embeds, so a copy of the shim, however it was renamed or moved, is recognized,
  • --version, run with a 2 second timeout and a 4 KiB output cap, does not answer like git. The probe runs with DRAWBAR_DEPTH already at its limit, so a wrapper that execs the shim refuses at once instead of looping.

A rejected candidate is skipped, except for an explicit override. A DRAWBAR_REAL_GIT or AGENT_GIT_REAL that names the shim or a copy of it fails resolution with exit 78 and a message naming the variable, because following it would loop and quietly running the next candidate would hide the mistake (ADR 0002).

As a second guard, every git the shim starts gets DRAWBAR_DEPTH one higher than its own. At 16 the shim refuses to run and exits 78.

The shim hands your arguments to git as raw bytes with no shell in between, so a repository path or argument is never reparsed. It adds only its own -c flags ahead of them. Its diagnostics are one line each, with any newline in a path or variable escaped, so a hostile file name cannot forge extra output lines.

The resolve cache

So that the common call stays under a millisecond, the shim caches the answer in $XDG_CACHE_HOME/drawbar/real-git.cache, or ~/.cache/drawbar/real-git.cache. XDG_CACHE_HOME and HOME count only when they are absolute paths. A hit costs one small file read and a stat of the opt directory, the cached git, and each higher-priority candidate that was skipped, and it spawns nothing. The entry is used only while the override variables, the opt directory’s modification time, and each stat (device, inode, size, mode and modification time) still match what was probed, so replacing or adding a candidate sends the next call back through the probes. A candidate whose probe failed is not cached. The shim writes the entry to a temporary file and renames it into place, so a concurrent call reads the old entry or the new one, never half of one. drawbar status reads the cache without writing it.

The lease lock file

Commands that rewrite refs and packs take an exclusive flock on <common-dir>/drawbar-lease.lock (Per-repo lease).

  • Close-on-exec. The lock file is opened with O_CLOEXEC, so git and any process git starts, such as a detached git maintenance or a hook, never holds the lease. The kernel releases it however the shim exits (ADR 0005).
  • Permissions. The shim creates the file exclusively (O_EXCL) with mode 0644 whatever the caller’s umask, so every user of the repository can open it to lock it from the moment it exists. Otherwise it opens the file read-only, since flock needs no write access, so a lock file that another user created still serializes both users. The shim sets the umask briefly before it starts any thread, so the change reaches no other file.
  • Refusal paths. When git cannot name a common directory, as outside a repository, the command runs unleased and git reports its own error. Once git has named it, a lock file that cannot be opened or locked stops the command with exit 75 and one line naming the file, because running git unleased there would bring back the races the lease prevents. A lease still held when the wait ends also exits 75. In both cases git never ran.
  • The lease is advisory. It orders processes that take it. A process that can open the file can also hold it, and everyone else waits, up to lease.timeout_secs (120 seconds by default), then exits 75.
  • Stamp. A taken lease sets the file’s modification time to now, which drawbar doctor uses to tell how long it has been held. A user who cannot write the file leaves the time as it was.
  • Signals. The shim forwards SIGTERM, SIGINT, SIGHUP and SIGQUIT to git and stops forwarding before it reaps git, so it never signals a process ID the kernel has handed to something else. When git dies of a signal, the shim turns off its own core dumps (RLIMIT_CORE and PR_SET_DUMPABLE to 0) and dies of the same signal.

Stopping fsmonitor daemons

drawbar gc-daemons only looks at processes whose real and effective user ID are yours. It signals a daemon by its exact PID through a pidfd, opened before it checks the PID’s owner, command line and start time again, so a PID that changes hands after the check is never signaled. It never matches by name with pkill -f. When the config file is ignored it stops nothing (ADR 0006).

Building Git

drawbar build-git downloads source and compiles it, so it checks the source first (ADR 0007):

  • Pinned digests. The SHA-256 of each supported tarball (Git 2.56.0 and 2.56.1, .tar.gz and .tar.xz) is in the binary, copied from kernel.org’s signed sha256sums.asc. drawbar does not fetch a checksum file at build time, because a digest fetched from the same mirror as the tarball proves nothing about the tarball.
  • Hash what is unpacked. The download, or a copy of --tarball, lands in a scratch directory under the cache directory. drawbar hashes that copy and unpacks the same copy, so a file that changes after the check never reaches tar. A mismatch stops the build before anything is unpacked.
  • Download. curl -fsSL --proto =https --tlsv1.2 from kernel.org’s mirror. tar runs with --no-same-owner.
  • Your digest is your decision. A version or tarball with no pinned digest builds only when --sha256 supplies one, and drawbar checks the file against it and nothing else.
  • Stage, verify, rename. make install writes to a staging directory. drawbar checks that libexec/git-core holds git-remote-https and git-fsmonitor--daemon, then renames the tree onto ~/.local/opt/git-<version>. A build that fails at any step removes its scratch and staging directories and leaves the destination untouched.
  • Never overwrite. drawbar refuses to build when the destination exists.
  • Bounded. make -j4 by default, and a refusal to start below 4 GiB of available memory, so a build on a shared machine cannot exhaust it.

Install and uninstall

drawbar install changes a short, fixed list of paths, all in your home directory (ADR 0008):

PathChange
~/.local/opt/drawbar/drawbarThe running binary, copied through a temporary file and a rename.
~/.local/bin/git, ~/.local/bin/drawbarSymlinks to that copy, each created under a temporary name and renamed over the old path.
~/.local/opt/drawbar/displaced/Hard links to any entry the symlinks replaced.
Git’s global config fileAn [init] defaultRefFormat = files block, appended only when init.defaultRefFormat is unset.
~/.local/opt/drawbar/gitconfig.markerA record of whether install appended that block and whether it created the file.
The systemd user unit directoryFour unit files, only with --timers, and drawbard.service, only with --drawbard.

What keeps it reversible:

  • Check, then change. Install reads every ~/.local/bin entry and the config value before it writes anything, so a refusal leaves the home directory as it was.
  • Replace only on request. An entry drawbar did not make is replaced only with --force, or with --adopt-legacy for the agent-git prototype’s symlink. --adopt-legacy decides by asking the filesystem whether the link resolves to the same file as ~/.local/opt/agent-git/git, never by comparing link text, because a symlinked ~/.local/bin or a .. after a symlink can make matching text point elsewhere. Install never replaces a directory.
  • Keep what was replaced. Install hard-links the old entry into displaced/ before the swap, and uninstall moves it back.
  • Edit git config the way git does. drawbar creates <file>.lock exclusively before it reads the file and renames the lock over the file to commit, so no git config write can land between its read and its write. A symlinked config file is locked and written at its target.
  • Strip the exact bytes. Uninstall removes the recorded bytes when the file still ends with them. When it does not, it runs git config --unset init.defaultRefFormat '^files$', which removes the value only while it is still files.
  • Never worktree.useRelativePaths. Install does not set it, because git older than 2.48 cannot read such worktrees.
  • Uninstall finishes. Each step runs even when an earlier one fails, every failure is reported, and a ~/.local/bin entry that no longer points at drawbar is left alone.

Deleting ~/.local/opt/drawbar by hand loses the displaced entries and the marker, and uninstall can then no longer restore ~/.local/bin/git or remove the config block.

The install script

deploy/install.sh downloads a release and hands it to drawbar install. It checks the download before it runs anything from it:

  • Checksum. It reads the archive’s SHA-256 from the release’s SHA256SUMS and stops, changing nothing, when the archive is not listed or the digest does not match.
  • Attestation. When gh is installed and signed in, it runs gh attestation verify against OttoOps/drawbar and stops when that fails. When gh is missing or not signed in, it says it skipped the check. The checksum file comes from the same release as the archive, so on its own it catches a corrupt or mismatched download. The attestation ties the archive to the release workflow’s build, which attests every release and signs and notarizes the macOS binaries (ADR 0010).
  • Local archives. --archive with --sums checks the checksum only and prints the gh attestation verify command to run yourself.
  • Transport. DRAWBAR_RELEASES_URL must be an https URL, or plain http on 127.0.0.1 or localhost, and curl follows redirects only to the same scheme.
  • Shape. The archive must be named drawbar-<version>-<target>.tar.gz and hold a drawbar binary that runs on this machine. It is unpacked into a temporary directory that the script removes on exit.

The systemd units

drawbar install --timers writes four units to the systemd user directory (~/.config/systemd/user, or under $XDG_CONFIG_HOME), and drawbar install --drawbard writes drawbard.service there, so nothing runs as root and nothing is system-wide (ADR 0009):

  • Every unit starts with a # drawbar unit: line. Install refuses, changing nothing, when a file at one of those names does not, or when systemctl --user show -p FragmentPath says systemd loads the unit from another file. Uninstall leaves such a file alone, and does not stop or disable a unit systemd loads from another file.
  • Both services are Type=oneshot, run %h/.local/bin/drawbar, and set PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin and LimitNOFILE=1048576. The maintenance service also runs at Nice=10 with idle I/O scheduling.
  • drawbar maintenance starts each repository’s run through the shim, so it takes the repository’s lease and waits its turn behind agents. Maintenance never bypasses the lease.
  • The units are built into the binary, so install --timers writes the units that match the binary it installs. Customize them with systemctl --user edit drop-ins, which drawbar does not touch.
  • Uninstall disables the timers and stops and disables drawbard.service before it removes any unit file, so a failed systemctl cannot leave an enabled unit with a dangling link.
  • drawbard.service runs %h/.local/bin/drawbar daemon with the same PATH and LimitNOFILE, and XDG_RUNTIME_DIR=%t. Its KillMode=mixed sends SIGTERM to the daemon alone, so the fetches it runs for other processes finish before it exits. Uninstall removes $XDG_RUNTIME_DIR/drawbar only when it belongs to you and no daemon holds its lock (ADR 0017).

The units set no sandboxing options such as ProtectHome. They run with your full user rights, like any other command you run.

Reporting a vulnerability

Report suspected vulnerabilities privately through the security policy, not in a public issue or pull request.

cargo-lane

contrib/cargo-lane is the cargo counterpart of the git shim. It is a cargo wrapper for a machine where several coding agents build in parallel. It keeps cargo mutants and the bigger cargo test and clippy runs from piling onto one desktop, and sends each run to wherever it costs least: the local machine, a boat sandbox, or GitHub Actions. It is bash, not part of the drawbar binary, and is installed on its own.

Where each run goes

RunGoes toWhy
cargo build, check, doc, bench, install and friendslocal, in the sliceAn editor or agent is waiting on them, and their output is needed here.
cargo metadata, fmt, run and every other subcommandlocal, untouchedLight, or the program itself.
cargo test, nextest, clippy, the machine is quietlocal, in the sliceFastest when nothing else is building.
The same, from an agent session, while the machine is busyone boat sandboxMoves the load off the desktop for about a cent a run.
cargo mutants with up to mutants_local_max (40) mutantsthe local laneOne run at a time, in a cgroup with no swap.
cargo mutants with more, under mutants_remote_max_dollars ($0.50)boat, shardedA whole-crate drawbar run takes 17 minutes for about $0.11.
cargo mutants over the cap and over mutants_local_hard_max (200)refused, exit 75Grade it on GitHub Actions, which is free for public repositories.
Nightly whole-crate gradingGitHub Actionsmutants-nightly.yml, skipped when the commit is already graded.

“Busy” means any of:

  • at least offload_min_rustc (8) rustc processes;
  • less than offload_min_mem_avail_gib (6) GiB available;
  • a load average per CPU of the repository’s LOAD (default offload_min_load, 1.25);
  • the repository’s RUNS (default offload_min_scopes, 2) other cargo runs active in the slice.

offload_repos lists OWNER/REPO[:LOAD[:RUNS]], so each repository gets thresholds that match its suite:

Suite (full cargo test)Here, idleOn boat, from the golden snapshotEntry
Inspan, 1,949 tests125 s after a one-file change, 251 s cold155 s, $0.003OttoOps/inspan:0.5:1
drawbar, 276 tests12 s32 s, $0.0006OttoOps/drawbar:1.0:2

One local Inspan run pushes the load average to 24-30 on 16 CPUs, stalls on memory (PSI memory 64%), and uses about 12 GiB. A second one at the same time would not fit. So Inspan offloads as soon as one other cargo run is active or the load reaches half the CPUs. drawbar’s suite is light, and boat slows it down, so it offloads only once the load reaches the CPU count or two other cargo runs are active. Offload covers only the listed repositories, and only calls from an agent session (CLAUDECODE, T3CODE_THREAD_ID or CODEX_THREAD_ID set). A copy of a repository without .git, such as a reviewer’s export in /tmp, is matched by the repository URL in its root Cargo.toml (the workspace root, the same tree that is packed) and packed by its .gitignore, plus any ignored Cargo.lock. A copy with neither .git nor .gitignore runs locally. IDE-style calls pass straight through: --message-format, --no-run, --target-dir, --manifest-path, --list and --fix. A run that boat cannot start runs locally instead.

The slice

Every local run that builds goes into one systemd user slice, cargo-lane.slice, as its own scope (cargo-lane-<subcommand>-<pid>.scope). The slice caps all of them together:

  • MemoryHigh=40% of RAM: past this, the kernel reclaims and slows the builds in the slice instead of the rest of the machine.
  • MemoryMax=50%: past this, the OOM killer stops the largest process in the slice (a rustc or a runaway test), and that one cargo run fails. Nothing outside the slice is touched.
  • MemorySwapMax=0: builds never push the desktop into swap.
  • CPUWeight=50: when the CPUs are contended, the desktop and other services get twice the share of an agent build.
  • CPUQuota at 75% of the CPUs, in the drop-in install.sh writes (cargo-lane.slice.d/50-cargo-lane-cpu.conf): agent builds and tests together never take every core, so the desktop keeps a quarter of the machine however many agents build at once.

Four agents each starting a cold build of a large crate can no longer take WSL2 down: the worst case is a failed build. Change the limits with systemctl --user edit cargo-lane.slice. scope=off in the config, or CARGO_LANE_SYSTEMD=0, runs builds without a scope. When XDG_RUNTIME_DIR is unset, as in Codex shells, cargo-lane uses /run/user/$UID. Without a reachable user systemd there, builds run directly and decisions.jsonl records them as unscoped. Nested cargo calls, such as the ones cargo-mutants makes, stay in their parent’s scope.

The local mutants lane

Every local cargo mutants run takes an exclusive flock on ~/.local/state/cargo-lane/mutants.lock and runs inside its own scope inside the slice with MemoryMax=12G and MemorySwapMax=0, with CARGO_BUILD_JOBS=4 and --jobs lowered to 2. A second run does not queue: it exits 75 at once and names the run that holds the lane, so an agent can narrow its run or try later instead of stacking another build. Set mutants_lane_wait to a number of seconds to wait instead.

The cap is not hypothetical: one drawbar mutant allocates without bound, and every local run of the shard that holds it peaked at exactly the 12 GiB cap before the OOM killer stopped that mutant’s test, which cargo-mutants then counts as caught.

A finished run is cached for mutants_cache_hours (6) under a key built from the commit, the uncommitted diff, the untracked files and the arguments, so an agent that asks again for the same tree gets the same mutants.out back without a rebuild. CARGO_LANE_FORCE=1 skips the cache. Only runs that finished grading (exit 0, 2, 3 or 4, with an outcomes.json) are cached.

Boat

mutants-remote packs the worktree, uncommitted changes included, starts one sandbox per shard with --no-env, and merges the shards into mutants.out/ as if cargo-mutants had run locally. boat-cargo does the same for one cargo test or clippy and streams its output. Both:

  • pack only what git ls-files --cached --others --exclude-standard lists, leaving out .env*, *.pem, credentials*, nested repositories and mutants.out;
  • start from the saved snapshot golden-<repo> when it exists, which holds a built target/ for the default branch, and from rust-base otherwise;
  • wait for the sandbox to finish hydrating before they copy files in, since files restored from a snapshot carry whole-second mtimes until then and cargo misses rebuilds;
  • delete every sandbox they started, on success, failure or interrupt;
  • refuse to start a sandbox when fewer than min_plan_hours (40) of the plan’s included hours are left.

cargo-lane golden OWNER/REPO... rebuilds the golden snapshots. The installer adds a daily cargo-lane-golden.timer for the repositories in golden_repos; enable it with systemctl --user enable --now cargo-lane-golden.timer.

GitHub Actions

mutants-nightly.yml grades the whole crate in 8 shards on ubuntu-latest every night and on demand. When it finishes, it posts a mutants/full commit status on the commit. A boat run of the whole crate on a clean checkout of a pushed commit posts the same status. The nightly run checks for it first and skips a commit that is already graded, so one commit is never graded twice. To grade a pushed branch for free:

gh workflow run mutants-nightly.yml -R OttoOps/drawbar --ref my-branch -f force=true

Installing

contrib/cargo-lane/install.sh
cargo-lane status

The installer copies the scripts to ~/.local/opt/cargo-lane, links cargo, cargo-lane, mutants-remote and boat-cargo into ~/.local/bin, installs cargo-lane.slice and the golden timer in ~/.config/systemd/user, and writes ~/.config/cargo-lane/config from config.example if there is none. ~/.local/bin has to come before ~/.cargo/bin on PATH. It refuses to replace a file it did not install. install.sh --uninstall removes the links, the copy and the timer, and leaves the config and state.

The shim finds the real cargo further down PATH, skipping any copy of itself, or uses CARGO_LANE_REAL. CARGO_LANE=off passes every call straight through. Each routing decision is appended to ~/.local/state/cargo-lane/decisions.jsonl, and cargo-lane status shows the last ten with the current lane holder and load.

Configuration

~/.config/cargo-lane/config holds key=value lines. Unknown keys are ignored with a warning. See contrib/cargo-lane/config.example for every key and its default. mutants_seconds_per_mutant holds measured shard-seconds per mutant on boat large, per repository, and drives the cost estimate.

See ADR 0012.

Architecture decisions

Settled, non-obvious architecture choices are recorded as ADRs in the repository’s docs/adr/ directory. Accepted ADRs are immutable: a later ADR supersedes one rather than editing it. ADRs 0001 to 0010 predate the template; new ones use MADR 4. The index lists them all and has the template.

Contributing

Bug reports, fixes, tests, documentation and platform ports are welcome. drawbar is pre-1.0, so CLI flags, config keys and daemon protocols may still evolve. Start with the contribution guide. It covers the DCO signoff every commit carries (git commit -s), how pull requests merge, and what stays out of code, fixtures and docs.

Report vulnerabilities privately through the security policy. Participation follows the Code of Conduct. The code is under the MIT license.

Checks

Run the checks CI runs, from the repository root:

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test --locked
cargo build --locked

CI runs them on ubuntu-latest and ubuntu-24.04-arm. A change that touches only docs/, .github/, LICENSE, .coderabbit.yaml or .gitignore, or only Markdown files in the repository root, skips them.

Commits and pull requests

Pull requests merge with Rebase and merge, so each commit stands on its own:

  • a Conventional Commit subject, 50 characters at most, in the imperative mood,
  • a DCO signoff (git commit -s),
  • a passing build and test suite.

Squash fixup commits before review ends. The DCO check must pass alongside check.

Architecture decisions

Record settled, non-obvious architecture choices as MADR ADRs under docs/adr/ and index them in docs/adr/README.md. Accepted ADRs are immutable: supersede, never edit. The existing ones are listed under Architecture decisions.

This site

docs/build.sh builds the site into docs/book/ with mdBook 0.5.4. CI builds it on every pull request, checks its links with lychee, and deploys it to GitHub Pages from main. The pages are Markdown under docs/src/, and docs/src/SUMMARY.md lists them in order. To build locally, install mdBook and run:

docs/build.sh

Point MDBOOK at an mdbook binary that is not on PATH.

Roadmap

  • Phase 1 (track: phase-1): Compiled git shim with cached real-git resolution, per-repo flock lease, scoped fsmonitor, build-git / install / uninstall, scheduled maintenance, and drawbar doctor / bench.
  • Phase 2 (track: phase-2): Optional drawbard user daemon for single-flight git fetch coalescing across concurrent workers, with fail-open fallback to the Phase 1 lease. It runs as drawbar daemon, installed as a systemd user service by drawbar install --drawbard, and drawbar status and doctor report it. See Running drawbard.
  • Phase 3 (track: phase-3): Cross-repo drawbar worktree audit / prune with safe fsmonitor--daemon teardown and build-artifact disk reporting.