Skip to content

CAS-2540 — Cargo-targets disk budget

CAS-2540 — Cargo-targets disk budget

Status: shipped (2026-05-13, commit 7d57df0)
Owner: Castellan (implementation), Master of Craft (architecture)

Problem

Recurring disk-full incidents blocked all engineering work. The Worktree Sweeper and Ravens disk probes caught the symptom but only after the crisis, and only through manual intervention. Each fill required a human-triggered migrate-worktree-cargo.sh run to recover.

What shipped

Five-layer structural fix:

LayerComponentWhat it does
1enforce-cargo-budget.shLRU eviction across all officer target dirs — evicts deps → build → incremental until under budget. Skips files younger than 5 min and respects the smoke-test lock.
2cargo-budgets.confPer-officer budget caps: backend/frontend 12 GB, others 6–8 GB. Config-driven — no code change needed to adjust.
3com.paperclip.cargo-budget-enforcer.plist.tmpllaunchd daemon: hourly enforcement (StartInterval=3600) + RunAtLoad=true. Replaces the 4-hour Paperclip routine (which ran only while Paperclip was up).
4cargo-budget-alert.shPer-role 80% threshold alert. Fires after each enforcement run; surfaced to Paperclip logs.
5enforce-cargo-budgets.shDispatcher wrapper wired into install.sh and check-daemon-health.sh.

Key behaviours

  • Smoke-lock guard — eviction is skipped when ~/.paperclip/state/smoke-test.lock is held by a live process. Prevents pruning incremental artifacts mid-smoke.
  • 5-minute safety window (MIN_AGE_MINUTES=5) — recently written files are never evicted. Protects in-flight builds.
  • Dry-run modeenforce-cargo-budget.sh --dry-run reports what would be evicted without touching disk.
  • Idempotent — safe to run multiple times; already-under-budget dirs are no-ops.

Files

.agents/skills/casaconomy-task-worktree/scripts/
enforce-cargo-budget.sh — main enforcer
cargo-budgets.conf — per-officer GB caps
.paperclip/
scripts/enforce-cargo-budgets.sh — dispatcher
scripts/cargo-budget-alert.sh — 80% alert
scripts/check-daemon-health.sh — wired in for health reporting
launchd/com.paperclip.cargo-budget-enforcer.plist.tmpl — daemon template
install.sh — registers daemon on setup

Follow-up (separate CAS)

  • Disk-level push notification
  • Post-merge hook integration
  • disk-budget-status.sh summary command
  • SKILL.md entry for task-worktree skill