Description
Problem Description
devops repos worktrees prune removes no worktree of a merged pull request when the worktree holds scratch files of its builder. AGENTS.md rule 12 tells an agent to put scratch files under .data/agent/scratch/, and in a worktree that path is inside the worktree. Prune counts these files as ignored data files and refuses the worktree.
Preview on 2026-11-26 in the devcontainer: Preview: 0 removable (0.0 B), 155 refused. The reasons: 103 outside the managed folder, 20 with no merged pull request for the tip, 17 that hold ignored data files, 8 dirty, 1 locked. .data/agent/worktrees holds 79 GB.
Five of the 17 were worktrees of pull requests that merged that day (#7297, #7306, #7320, #7332, #7336). Each held only .data/agent/scratch/ files (probe scripts, logs, pull request bodies), .data/rag/ index caches and .hypothesis/.
Expected vs Actual Behavior
- Expected: prune removes the worktree of a merged pull request whose only ignored files are agent scratch files and caches that can be made again.
- Actual: it refuses each such worktree, so a person or an agent removes them by hand with
git worktree remove --force.
Proposed Fix
Count .data/agent/scratch/, .data/rag/ caches and .hypothesis/ of a worktree as data that can be made again, as .venv and .data/cache are, or print the ignored files and take them with an option.
Acceptance Criteria
- A test: a clean worktree of a merged pull request that holds only
.data/agent/scratch/files and.hypothesis/is removable. - A test: a worktree that holds another ignored data file is refused as before, and the refusal names the file.
Environment Diagnostics
devops-cli 0.223.3.
Alternatives check of 2026-11-26: none.
Tool: none found.
Reason: Searches surfaced only generic worktree managers and git itself; none detects merged pull requests for a worktree tip or separates regenerable scratch/cache paths from other ignored data, so the change belongs in the project's own pathspec list.
Lacks:
- Merged-pull-request check for the worktree tip
- Regenerable-path policy for scratch, RAG caches and .hypothesis
- Refusal that names the offending ignored file
Proposed design
Problem statement
devops repos worktrees prune refuses the worktree of a merged pull request when the worktree holds only agent scratch files and regenerable caches. The preview reports 0 removable and 155 refused. Five refused worktrees of pull requests merged that day held only .data/agent/scratch/, .data/rag/ and .hypothesis/ files. A person or an agent must remove each worktree by hand with git worktree remove --force.
Acceptance criteria
Requirement: Regenerable ignored files are removable
devops repos worktrees prune SHALL remove the worktree of a merged pull request when its only ignored files are .data/agent/scratch/, .data/rag/ and .hypothesis/ files.
Scenario: Merged worktree with agent scratch and caches
- WHEN A test creates a worktree of a merged pull request with only
.data/agent/scratch/,.data/rag/and.hypothesis/files ignored. - THEN The prune command removes the worktree and reports it as removed.
Requirement: Other ignored data is refused and named
devops repos worktrees prune MUST refuse a worktree that holds an ignored file outside the regenerable paths and MUST name that file in the refusal.
Scenario: Merged worktree with other ignored data
- WHEN A test creates a worktree of a merged pull request with one ignored file outside
.data/agent/scratch/,.data/rag/and.hypothesis/. - THEN The prune command refuses the worktree and its reason names the ignored file.
Requirement: Existing regenerable paths stay removable
devops repos worktrees prune SHALL keep .venv and .data/cache as regenerable paths.
Scenario: Existing cache paths stay removable
- WHEN A test creates a worktree of a merged pull request with only
.venvand.data/cachefiles ignored. - THEN The prune command removes the worktree.
Existing Tool Considered
The alternatives check in the issue body records verdict none and no tool. The project builds the change itself by extending its existing pathspec list. Estimated cost is about 10k tokens and 2 hours to build, keep and fix the path policy and its tests.
Key questions
- How should prune treat agent scratch and cache paths?: Add
.data/agent/scratch/,.data/rag/and.hypothesis/to the existing regenerable pathspec list. Keep other ignored data refused and name the offending file. (best practice) [sources: AGENTS.md]- Chosen: Extend the regenerable pathspec list. AGENTS.md rule 12 puts agent scratch under
.data/agent/scratch/, and the issue shows these paths are regenerable. - Rejected: Print ignored files and require an option. This keeps the manual removal step that the issue reports.
- Rejected: Force remove every worktree with ignored files. This would delete data that cannot be made again.
- Chosen: Extend the regenerable pathspec list. AGENTS.md rule 12 puts agent scratch under
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 26, 2026
Both items extend the regenerable path list in CONST_WORKTREE_REGENERABLE_PATHSPECS, but #6636 adds .venv in subdirectories while the candidate adds .data/agent/scratch/, .data/rag/, and .hypothesis/.devops-cli-service commentedon Nov 26, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (9)
Tools considered:
Searches run:
Sources:
devops-cli-service commentedon Nov 28, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
devops-cli-service commentedon Nov 29, 2026
Released in v0.242.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.242.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 03:13 UTC