Expand description
Puts the build slot where agents’ shells find it, so only one heavy build or test runs
at a time on a machine: docs/specs/SPEC_BUILD_SLOT_ENFORCEMENT_2026_10_20.md.
Two kinds of file are installed, both taken from scripts/build-slot/:
~/.agentmux/shared/locks/build-slot.sh, the lock itself. Every AgentMux channel on the machine shares it, so it is only replaced by a newer version (# build-slot-version: N), never by an older channel’s copy.- A shim per heavy tool (
cargo,task,npm,npx,docker, each with a.cmdtwin) in~/.agentmux/tools/bin, the user tools directory that agents’ shells put ahead of the system PATH (tool_store::tools_path). All are the same two files under different names; they send the tool’s heavy subcommands through the lock. A file at that path that does not carry the shim’s marker is somebody’s own and is left alone.
Installing never fails startup: the caller logs an error and goes on. The shims fail open too, so a missing or broken lock script costs nothing but the protection.
Structs§
- Installed
- What one
installcall did. - Slot
Holder - Who holds the build slot right now, read from the lock’s owner file.
Functions§
- clear_
idle - Removes the idle note: the holder is busy again, or gone.
- holder
- The current holder of this machine’s build slot, if there is a live one.
- install
- Installs the lock script and both shims under
home, writing only what is missing or older. - install_
for_ current_ user - Installs for the current user’s home directory.
Okwith nothing written when there is none, and when this AgentMux is isolated (AGENTMUX_HOME_OVERRIDE): the lock and the shims are shared by every AgentMux on the machine, so a test or capture instance must not change them. - lock_
dir ~/.agentmux/shared/locks/build, the lock’s own folder, orAGENTMUX_BUILD_SLOT_DIRwhen that is set (the script honours it too).- read_
holder - The holder recorded under
rootatnow_secs: none when the slot is free, when its owner file is not written yet, or when nobody has kept it alive forSTALE_SECS(a dead holder). - script_
path ~/.agentmux/shared/locks/build-slot.shunderhome.- shim_
dir ~/.agentmux/tools/binunderhome: the shims’ directory.- shim_
function_ env - Environment variables that make a bash started with them define
cargo,task,npm,npxanddockeras functions calling the shims underhome(BASH_FUNC_cargo%%and so on: bash imports an exported function from its environment). - shim_
function_ env_ for_ current_ user shim_function_envfor the current user’s home, with the slot’s off switch read from the environment.- write_
idle - Records that the holder with
tokenhas been idle sincesince_secs(epoch seconds). Does nothing when the slot now belongs to another holder: a note about the last run must never land on the next one.