Skip to content

Allow ignored artifacts in verified merge cleanup - #1964

Merged
mergify[bot] merged 3 commits into
mainfrom
lean178/575-clean-ignored-worktrees
Nov 26, 2026
Merged

mergify[bot] merged 3 commits into
mainfrom
lean178/575-clean-ignored-worktrees

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Allow ignored artifacts in verified merge cleanup

Context and goal

  • Context: On miki, 129 verified merged or closed worktrees still exist and occupy 103.26 GiB after excluding nested double counting. The loop-zero and IntelFlo worktree registries were measured with idle-priority du -skx.
  • Problem: The ignored-file veto leaves completed worktrees with generated artifacts behind.
  • Goal: Let verified merge cleanup remove an otherwise clean checkout with ignored artifacts while retaining checkouts with work in progress or a nested worktree.

Refs #575

Acceptance

  • An ignored virtual environment alone allows normal non-forced Git cleanup.
  • Non-ignored untracked files block cleanup and keep both the files and branch.
  • Ignored nested worktrees block cleanup, including linked worktrees registered with a different repository.
  • Verified head, branch and dirty-worktree guards still apply. No pre-existing worktrees are manually removed.

Validation

Recorded for 0f847e4ae631

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0
  • Focused worktree suite: 40 passed.
  • Fixture cases cover ignored-only removal, mixed ignored and untracked work, and nested worktrees from two registries.

Review

(filled by loopzero review)


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

  • primary, claude, 5e2355d, request_changes
  • delta, claude, 0f847e4, approve

Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on 5e2355d714f229d142d0994f1b975d6537f395e8, 22.7s: request_changes (0 critical, 1 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/worktree.py Resolved
Comment thread src/loopzero/worktree.py Outdated
raise WorktreeError(f"could not inspect nested worktrees in {wt}: {exc}") from exc

# Other repositories' linked worktrees are absent from this Git registry.
for path, _, files in root.walk(on_error=fail_scan):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Full-tree walk visits every file in large ignored artifacts

root.walk() lists every directory under the worktree, including large ignored trees such as .venv and node_modules. The PR exists to clean up exactly these trees, which hold about 100 GiB across 129 worktrees. The scan also runs while the ref lock is held, and _lock_verified_ref has only a 30 s prepare timeout. It is correct but may be slow. If it matters, prune dirs in place to skip entries that are themselves nested-checkout roots once found, or document the cost. No change is required.

eowca and others added 2 commits November 26, 2026 16:19
Architecture-Review: unchanged; the nested checkout safeguard applies to linked and standalone Git checkouts.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero delta review by claude on 0f847e4ae631b995e98b874cf8972ce398aeeb5f, 13.8s: approve (0 critical, 0 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/worktree.py

# Other repositories' checkouts are absent from this Git registry.
for path, directories, files in root.walk(on_error=fail_scan):
if path != root and (".git" in files or ".git" in directories):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Nested-repo scan only recognises entries named .git, so ignored bare repositories are still deleted

The widened check now catches standalone clones, where .git is a directory. Linked worktrees, where .git is a file, were already caught, and symlinks also land in files because Path.walk does not follow them. A bare repository nested under an ignored path (for example ignored/mirror.git/ containing HEAD, objects/ and refs/) has no .git entry. It passes the scan, and the non-forced git worktree remove deletes it. If that case matters, the smallest fix is to also treat a directory containing HEAD plus objects/ and refs/ as a repository. Otherwise, document the limitation in the comment at line 384. This is not a regression: the previous code missed it too.

@eowca
eowca marked this pull request as ready for review November 26, 2026 15:28
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 1a71ce1 at 15:34 UTC

5 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 15:29 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1970
  • ✅ Merged 15:34 · 1a71ce1 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 1a71ce1 into main Nov 26, 2026
19 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/575-clean-ignored-worktrees branch November 26, 2026 15:35
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