Skip to main content

Module build_slot

Module build_slot 

Source
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 .cmd twin) 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 install call did.
SlotHolder
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. Ok with 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, or AGENTMUX_BUILD_SLOT_DIR when that is set (the script honours it too).
read_holder
The holder recorded under root at now_secs: none when the slot is free, when its owner file is not written yet, or when nobody has kept it alive for STALE_SECS (a dead holder).
script_path
~/.agentmux/shared/locks/build-slot.sh under home.
shim_dir
~/.agentmux/tools/bin under home: the shims’ directory.
shim_function_env
Environment variables that make a bash started with them define cargo, task, npm, npx and docker as functions calling the shims under home (BASH_FUNC_cargo%% and so on: bash imports an exported function from its environment).
shim_function_env_for_current_user
shim_function_env for the current user’s home, with the slot’s off switch read from the environment.
write_idle
Records that the holder with token has been idle since since_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.