Skip to content

feat(workspace): report worktree disk cleanup pressure#149

Merged
chubes4 merged 1 commit into
mainfrom
fix-worktree-disk-cleanup-intelligence
Apr 30, 2026
Merged

feat(workspace): report worktree disk cleanup pressure#149
chubes4 merged 1 commit into
mainfrom
fix-worktree-disk-cleanup-intelligence

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Apr 29, 2026

Summary

  • Add disk-pressure reporting to workspace worktree list/cleanup output: estimated sizes, age, stale reason, artifact profiles, top repo/worktree summaries, and size/age cleanup sorting.
  • Keep cleanup destructive behavior conservative while surfacing non-destructive artifact visibility for large build/cache directories.
  • Expand cleanup GitHub PR lifecycle detection so bounded cached lookups distinguish merged PRs from closed-unmerged PRs.

Incident context

On 2026-04-29, /Users/chubes/Developer had 787 worktree-like directories using about 712.6 GiB. homeboy@* alone accounted for 215 directories and about 592.0 GiB; removing 208 clean Homeboy worktrees freed about 572.7 GiB.

This PR makes that kind of pressure visible before cleanup becomes an emergency, without loosening the existing dirty/unpushed safety gates.

Changes

  • Adds disk metadata to worktree list rows: size_bytes, estimated_size_bytes, last_touched_at, age_days, artifact_size_bytes, artifacts, and stale_reason.
  • Adds --stale to workspace worktree list for quick old/dirty/missing-metadata review.
  • Adds cleanup summary totals and repo buckets for worktree size and artifact size, plus top_by_size / top_by_age JSON summaries.
  • Adds --sort=size|age for cleanup candidate ordering.
  • Adds non-destructive artifact profile reporting for Rust target, Node build/dependency caches, and Composer vendor, with a datamachine_code_worktree_artifact_profile filter.
  • Changes GitHub cleanup lookup from merged-only to closed same-repo PRs so merged branches get pr-merged and closed-unmerged branches get pr-closed.

Tests

  • php -l inc/Workspace/Workspace.php && php -l inc/Cli/Commands/WorkspaceCommand.php && php -l inc/Abilities/WorkspaceAbilities.php && php -l tests/smoke-worktree-cleanup-cli.php && php -l tests/smoke-worktree-cleanup.php && php -l tests/smoke-worktree-cleanup-github-cache.php
  • php tests/smoke-worktree-cleanup-cli.php
  • php tests/smoke-worktree-cleanup.php
  • php tests/smoke-worktree-cleanup-github-cache.php
  • php tests/smoke-worktree-lifecycle-metadata.php
  • git diff --check

Focused homeboy lint --file runs still report existing PHPStan baseline issues in the large touched files; PHPCS formatting is clean for the production files touched by this PR.

Closes #144
Refs #142
Refs #145

AI assistance

  • AI assistance: Yes
  • Tool(s): OpenCode (GPT-5.5)
  • Used for: Implemented the cleanup reporting changes, updated smoke coverage, ran focused verification, and drafted this PR description. Chris remains responsible for review and merge.

@chubes4 chubes4 force-pushed the fix-worktree-disk-cleanup-intelligence branch from 4f64a7c to bd8f988 Compare April 30, 2026 00:17
@chubes4 chubes4 merged commit 0cdda95 into main Apr 30, 2026
@chubes4 chubes4 deleted the fix-worktree-disk-cleanup-intelligence branch April 30, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Surface stale worktree age and size in list/cleanup

1 participant