Repository navigation
reclaim_disk.sh: prune finished lane worktrees and merged branches; doctor disk-free row - #2428
Merged
Merged
Conversation
…octor disk-free row New .claude/skills/agentic-delivery/scripts/reclaim_disk.sh lists (default) or removes (--apply) linked worktrees that are unlocked, have no modified, untracked or ignored files, are not mid rebase, merge, cherry-pick, revert or bisect, have no assume-unchanged entries or skip-worktree entries whose file is on disk, are older than RECLAIM_MIN_AGE_HOURS (default 24) and whose HEAD is reachable from another branch. It then lists local branches merged into origin/main (else main), skipping protected names and branches checked out in a worktree that stays. It never forces: git worktree remove runs without --force, and git branch -D -- <name> runs only after the merge check; a refusal prints a skip line. Inherited repo-local GIT_* variables are unset first, so a GIT_DIR from a hook or parent process cannot make it judge another repository and orphan an unpushed detached lane. A sparse-checkout lane (skip-worktree entries whose files are absent) is no longer blocked. perun_doctor.py gains a "disk free" row (disk_free): WARN under 50 GiB, FAIL under 10 GiB (PERUN_DISK_WARN_GB / PERUN_DISK_FAIL_GB), naming reclaim_disk.sh below the warn line. Under DCR_NO_PROBE=1 the row is INFO, like the other host probes, so the doctor tests no longer depend on the CI runner's free space. scripts/test_reclaim_disk.py removes GIT_* from its environment and builds hermetic repos. It covers each guard (deleting any "# guard:" line fails the test, 12/12), a sparse lane, a run with GIT_DIR and GIT_INDEX_FILE pointing at the main repo, a re-run of the whole test under a decoy GIT_DIR that must leave the decoy repo's refs, config and worktree list untouched, and the doctor row under DCR_NO_PROBE. Registered in scripts/ci-tests.d/reclaim-disk.sh. The operating-discipline teardown section names the script and points to docs/perun-doctor.md for the thresholds; the agentic-delivery lookup cost stays under its bound (22599 < 22601). size-budget-raise: .claude/skills/agentic-delivery/references/operating-discipline.md 11608→11812 adds the disk-hygiene line to the teardown section Tests: 84/84 (test_reclaim_disk 1 with guards 12/12, test_perun_doctor 26, test_install_ux 32, test_extra_hosts_install 6, test_hosts_parity 6, test_skill_index_split 7, test-perpr-shard-balance 6); size, fragments and privacy gates clean; shellcheck clean Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #2426. Rebased on current main as one squashed commit.
What
reclaim_disk.shprunes worktrees of finished lanes and merged branches. It is dry-run by default and changes nothing without--apply.perun_doctor.pygains a disk-free row that warns below 50 GiB free.Tests
84/84 (test_reclaim_disk 12/12 guards, test_perun_doctor 26, test_install_ux 32, test_extra_hosts_install 6, test_hosts_parity 6, test_skill_index_split 7, test-perpr-shard-balance 6). Size, fragments and privacy gates are clean, and shellcheck is clean.
Independent review: SHIP
These 🟡 follow-ups go in the next PR:
reclaim_disk.sh:34: a 0x01 byte in a path splits fields aftertr. Map\0\1to\1\2and test for\2.reclaim_disk.sh:44:--ignoredskips lanes that hold__pycache__ornode_modules. Measure the GiB freed on a real repo.perun_doctor.py:203: the WARN below 50 GiB sets exit 1 on small but healthy disks. Keep WARN off the exit code.perun_doctor.py:205: the hint path is cwd-relative. Prefix it withcd {repo} &&.test_reclaim_disk.py:173: the decoy child clearsGIT_*, so it only tests the harness. Run--applythroughsh(extra=).🤖 Generated with Claude Code
https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc