Skip to content

reclaim_disk.sh: prune finished lane worktrees and merged branches; doctor disk-free row - #2428

Merged
remigiusz-antczak merged 2 commits into
mainfrom
disk-hygiene-1118b
Nov 18, 2026
Merged

remigiusz-antczak merged 2 commits into
mainfrom
disk-hygiene-1118b

Conversation

@remigiusz-antczak

Copy link
Copy Markdown
Collaborator

Supersedes #2426. Rebased on current main as one squashed commit.

What

  • reclaim_disk.sh prunes worktrees of finished lanes and merged branches. It is dry-run by default and changes nothing without --apply.
  • perun_doctor.py gains 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 after tr. Map \0\1 to \1\2 and test for \2.
  • reclaim_disk.sh:44: --ignored skips lanes that hold __pycache__ or node_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 with cd {repo} &&.
  • test_reclaim_disk.py:173: the decoy child clears GIT_*, so it only tests the harness. Run --apply through sh(extra=).

🤖 Generated with Claude Code
https://claude.ai/code/session_01B4dfwdDQiF3RQMUqYBqefc

…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
@remigiusz-antczak
remigiusz-antczak merged commit f380162 into main Nov 18, 2026
13 checks passed
@remigiusz-antczak
remigiusz-antczak deleted the disk-hygiene-1118b branch November 18, 2026 12:40
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.

1 participant