huskies: merge 1199 story Orphaned build-dir GC: reclaim dead worktree targets without touching warm caches

This commit is contained in:
Huskies Agent
2026-07-17 20:57:21 +00:00
parent 2bd41d980c
commit 5b340e7b20
18 changed files with 565 additions and 5 deletions
+39
View File
@@ -241,6 +241,45 @@ pub(crate) fn spawn_tick_loop(
&disk_watch_status,
&disk_watch_host_id,
);
// Orphaned build-dir GC (story 1199): tied to the same
// low-disk signal as the watchdog above rather than its own
// timer. `gc_min_free_gb == 0` (default) disables this —
// the on-demand `gc` MCP tool remains available regardless.
let gc_min_free_gb = config::ProjectConfig::load(r)
.map(|c| c.gc_min_free_gb)
.unwrap_or(0);
if let Ok(free_bytes) = service::disk_watch::io::free_space_bytes(r)
&& service::gc::should_auto_run(gc_min_free_gb, free_bytes)
{
let gc_root = r.clone();
tokio::spawn(async move {
service::gc::io::run_gc_pass(&gc_root).await;
});
}
}
// Orphaned build-dir GC (story 1199): if free disk falls below
// `gc_min_free_gb`, run a GC pass to reclaim orphaned worktree
// `target/` dirs and a stale `merge_workspace`. Checked on the
// same disk-space tick as the low-disk watchdog above — not a
// separate timer — so GC only ever runs in response to an actual
// low-disk condition. `gc_min_free_gb` absent or 0 disables this
// (the on-demand `gc` MCP tool still works).
if tick_count.is_multiple_of(30)
&& let Some(ref r) = root
{
let gc_min_free_gb = config::ProjectConfig::load(r)
.map(|c| c.gc_min_free_gb)
.unwrap_or(0);
if let Ok(free_bytes) = service::disk_watch::io::free_space_bytes(r)
&& service::gc::should_auto_run(gc_min_free_gb, free_bytes)
{
let root_for_gc = r.clone();
tokio::spawn(async move {
service::gc::io::run_gc_pass(&root_for_gc).await;
});
}
}
// Periodic reconciler: converge subscriber side effects so that