Expand description
Clearing agents’ cargo build caches and warning when a disk runs low
(docs/specs/SPEC_BUILD_CACHE_CLEANUP_2026_10_26.md).
Three hosts nearly filled their disks in two days from agents’ target folders. On one of
them 67% of 1 TB of targets was target/<profile>/incremental, and 90% of that was the
agentmux_srv crate: every change to a dependency gives the crate a new incremental
directory (about 10 GB) and the old one is never reused or collected.
Three things are done here, none of which can break a build (the worst case of a wrong guess is a slower incremental rebuild):
- Orphans: in each
incrementalfolder, the newest few directories per crate are kept and older ones idle for a day are removed. - A finished task: the agent’s own clones lose all their
incrementalfolders. - Abandoned clones: a clone nobody built in for days loses its whole
target(when a task finishes, or the disk is low).
A clone with a cargo, rustc, linker or test process running in it is never touched. Every
removal is logged, naming the workspace. This file is the file-system and policy part;
build_cache_service.rs runs it on a schedule and sends the warnings.
Structs§
- Policy
- What is cleared, and when the disk warning fires.
- Removed
- One removal.
- Report
- What a pass over one workspace did.
- Target
Size - A clone’s
targetsize and how much of it isincremental.
Enums§
- Why
- What a pass is for; it goes in the log.
Constants§
- KEY_
ENABLED - Settings keys (in the settings file’s free-form part).
- KEY_
ORPHANS - KEY_
ORPHAN_ IDLE_ HOURS - KEY_
ORPHAN_ KEEP - KEY_
STALE_ DAYS - KEY_
WARN_ FREE_ GB - KEY_
WARN_ FREE_ PCT
Functions§
- build_
running_ in - Whether a build seems to be running in
clone: a process whose working directory, executable or command line is inside it and which is a compiler, linker, cargo or something run from thetargetfolder. Looks at the machine’s processes now. - clones_
in - Every cargo clone in an agent’s workspace: the workspace itself or a folder directly in it
that has a
Cargo.tomland atargetfolder. - dir_
size - The size of everything under
p, in bytes. - disk_of
- The free and total bytes of the disk that holds
path. - human
- “193 GB”, “4.7 GB”, “820 MB”.
- incremental_
roots - The
incrementalfolders of atarget:target/<profile>/incrementaland, for a cross build,target/<triple>/<profile>/incremental. - last_
build - When something was last built in
target: the newest change among the target, its profile folders and the folders cargo writes to on every build. - log_
path - Where removals are logged (
AGENTMUX_BUILD_CACHE_LOGoverrides it, for tests). - orphans_
in - The incremental directories under
rootto remove: per crate, everything beyond the newestkeepthat has been idle foridleas ofnow. - run_
pass - One pass over the clones of
workspace. - snapshot_
processes - A snapshot of the machine’s processes, for
build_running_in. - target_
sizes - The size of every clone’s
targetinworkspace, largest first.