Repository navigation
Preserve ignored user files during merged worktree cleanup - #1556
Conversation
Refuse local cleanup if Git reports ignored files other than task text and receipts. This keeps local notes and settings where the developer left them. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
loopzero primary review by claude on f48b9514ec7b1fc3fcbe301a75d92356ed2fd754, 45.4s: approve (0 critical, 0 important, 4 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)
Findings without a file location:
- suggestion: No direct test that checks.json and review receipts still allow cleanup — Acceptance requires that a checkout with only loop-zero artifacts still cleans up.
test_cleanup_removes_worktree_and_branchcovers onlytask.md.test_already_merged_finishes_partial_cleanupcovers one review receipt, through the CLI. No test exercises.loopzero/checks.json, a delta receipt, or the symlinked-receipt refusal. Add these to the worktree-level test: writechecks.jsonplusreview-<12hex>-primary.json/-delta.jsonand assert removal succeeds, then make one of them a symlink and assert cleanup refuses.
Native Claude output is retained in the restricted local review receipt.
| for path in ignored.split("\0")[:-1]: | ||
| if ( | ||
| (path in {".loopzero/task.md", ".loopzero/checks.json"} | ||
| or re.fullmatch(r"\.loopzero/review-[0-9a-f]{12}-(primary|delta)\.json", path)) |
There was a problem hiding this comment.
suggestion: Receipt filename allowlist duplicates the naming in cli._review_file and runners
The new regex \.loopzero/review-[0-9a-f]{12}-(primary|delta)\.json and the literals .loopzero/task.md and .loopzero/checks.json repeat naming that is also defined in three other places: cli._review_file (cli.py:1103), cli.CHECKS_FILE (cli.py:30) and the receipt-path strings in runners.py:672/1003. If a receipt name or review kind changes, cleanup will start refusing to remove every merged worktree. The only symptom is a warning, so the drift would go unnoticed. Smallest fix: define the receipt-name pattern once in worktree.py, next to task_file, and use it from cli/runners. Alternatively, add a test that builds the receipts through the real writers (cli._save_report / cli._save_review) and then calls worktree.cleanup, so drift fails CI.
| ignored = _git( | ||
| wt, "ls-files", "--others", "--ignored", "--exclude-standard", "-z", preserve_newlines=True | ||
| ) | ||
| for path in ignored.split("\0")[:-1]: |
There was a problem hiding this comment.
suggestion: Leftover atomic-write temp files permanently block cleanup
_write_json_atomically (cli.py:384) and _initialize_task (worktree.py:190) create temp files inside .loopzero/ named .checks.json-*, .review-…json-* and .task.md-*. If the process is killed before the temp file is unlinked, it stays behind as an unknown ignored file. Cleanup then refuses on every loopzero merge rerun until the user finds and deletes it by hand. Refusing is the safe choice, but these are loop-zero's own artifacts. Consider allowing those exact temp-name prefixes, or have the error message say that .loopzero/.*-XXXX temp files are safe to delete.
| raise WorktreeError(f"no such worktree: {wt}") | ||
| if is_dirty(wt): | ||
| raise WorktreeError(f"worktree is dirty, refusing to remove: {wt}") | ||
| ignored = _git( |
There was a problem hiding this comment.
suggestion: Ignored build/dependency caches now block cleanup and are fully enumerated
ls-files --others --ignored without --directory walks into every ignored tree, such as .venv/, node_modules/ or __pycache__/. Two effects: (a) any developer who ran tests or installed dependencies in the task worktree now gets a refusal that names only the first file, and (b) the listing can be very large and slow under the git timeout. Refusing on these files matches the stated goal, but the warning only says "fix the cause" (cli.py:1162). Consider reporting the top-level ignored directory, or a count of ignored files, so the user can decide quickly. Also consider documenting that build caches have to be removed before cleanup.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Preserve ignored user files during merged worktree cleanup
Context and goal
Closes #1534
Acceptance
Base
main @ 11dc91c
Base: 11dc91c
Validation
Recorded for
f48b9514ec7buv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.Review