Skip to main content

Module clean

Module clean 

Source
Expand description

The disk janitor: finished runs get their worktrees folded and the shared build cache is pruned to its cap. A run whose state magi cannot read is left alone here — see fold_due — and is only ever removed by an explicit operator action (magi fold, or the equivalent phone route).

Everything policy-shaped — which statuses are foldable, how long a finished run is left alone, whether the cache is over its limit — is a pure function injected with numbers, so nothing here has to ask the operating system to be testable. The only I/O is the removal itself.

Structs§

Housekeeping
What one janitor pass did, for the caller’s log line.

Functions§

cache_report
The cache’s path, size and cap, for magi cache show and the health view. None when the config declares no CARGO_TARGET_DIR to aggregate.
cache_size
Size in bytes of the shared build cache.
due
Is updated old enough, measured against now, that the run may fold?
fold_due
Fold every run that is finished, older than the grace period, and not being worked on; count them.
fold_unreadable
Remove a run that cannot be read: its state directory under runs and its worktree directory under worktrees_root.
housekeep
Run the janitor: fold due runs, then prune the cache if it is over its cap.
prune_cache
Delete files from the shared build cache until it fits its cap.