Skip to content

fix(hooks): let cleanup_worktrees remove worktrees left with only regenerable outputs - #235

Merged
furedea merged 2 commits into
mainfrom
fix/cleanup-regenerable-outputs
Nov 18, 2026
Merged

furedea merged 2 commits into
mainfrom
fix/cleanup-regenerable-outputs

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

概要

cleanup_worktrees.py が,マージ済みで再生成できる生成物しか残っていない worktree を残していた問題を直した.判定は名前の許可リストのままで,git clean -fdX 方式にはしていない.

変更

  • 入れ子の .claude/ に .cc-writes しか無い場合も session scratch として扱う(is_session_scratch が最初の .claude 要素を探す).
  • REGENERABLE_NAMES に次の名前を追加した.
名前 生成する道具 再生成できる根拠
.hypothesis Hypothesis(pytest) 例の DB とキャッシュで,テストを再実行すれば作り直される
.astro Astro 型定義とキャッシュで,astro sync・astro build が作り直す
dist ビルド道具(Astro,Vite,Python の build など) ビルド出力で,ビルドし直せば作られる
test-results Playwright・Vitest などのテスト実行 実行結果で,テストを再実行すれば作られる
.pnpm-store pnpm 内容アドレス指定の store で,pnpm install が取得し直す

加えなかった名前

  • .wrangler: .wrangler/state に,ローカルの D1・KV・R2 の開発データが入りうる.再生成できない可能性があるので残す(テストで確認).

保った保護

  • tracked file を含む祖先は消さない(is_regenerable は変更なし).
  • .env など許可リストに無い ignored file が残る worktree は従来どおり残す.
  • .claude/ に .cc-writes 以外があれば残す(入れ子でも).

確認

  • uv run --frozen pytest -k cleanup: 247 passed
  • ruff check・format が通る
  • .github/workflows/ の変更なし
範囲外

マージ済み判定,trust check,Herdr workspace の扱い,git clean -fdX への切り替え,他の repository は変更していない.

Closes #232
Refs #169

🤖 Generated with Claude Code

@furedea

furedea commented Nov 18, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T05:41:45.625766Z 90de501 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Review summary: I found no P0–P3 issues, so I posted no inline comments.

  • is_session_scratch now locates the first .claude component at any depth. It still rejects a symlinked or missing .claude, still keeps the worktree when a nested .claude/ holds anything besides .cc-writes, and still treats an explicit .cc-writes entry as scratch. I couldn't find a way to delete a path this newly treats as scratch that the old code would have kept for a good reason.
  • The new REGENERABLE_NAMES entries go through is_regenerable, which skips any ancestor that holds a tracked file. A tracked dist/ or test-results/ is therefore still protected. dist is a generic name, so an untracked, ignored dist/ with hand-made content would now be removed. That's the same trade-off already accepted for target and result, and the PR states it.
  • Tests cover each new name, nested .cc-writes, a nested .claude with a non-scratch sibling, and the .wrangler exclusion.

I only read the diff and the surrounding code in cleanup_worktrees.py. I did not run the test suite. The PR reports 247 passed.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: f974c19466

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 18, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary: I found no blocking issues and posted no inline comments.

  • is_session_scratch now looks for the first .claude path component at any depth. It checks the symlink and is-directory conditions on that nested directory, and keeps the "only .cc-writes inside" rule. The nested cases I traced behave correctly: a/b/.claude/ reported as a directory entry, a/b/.claude/.cc-writes, and a nested .claude that also holds other ignored files, which still keeps the worktree.
  • is_regenerable is unchanged, so tracked files under an ancestor still protect it. .wrangler is deliberately left out and a test covers that.
  • New tests cover each added name, the nested .claude cases, and the .wrangler exclusion.

I did not run the tests here. This was a read-only review.

P3 (optional): dist and test-results match at any depth, like node_modules does. An ignored hand-written file under a directory that happens to be named dist would be deleted along with the worktree. That fits the allowlist design the PR describes, but it is worth knowing.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 90de501ea5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit a25ce5b into main Nov 18, 2026
29 checks passed
@furedea
furedea deleted the fix/cleanup-regenerable-outputs branch November 18, 2026 05:55
furedea pushed a commit that referenced this pull request Nov 19, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.3.0](v0.2.0...v0.3.0)
(2026-11-19)


### Features

* **lint:** fit the bash and yaml model rule cutoffs
([#243](#243))
([d5eab6b](d5eab6b))
* **lint:** fit the Go model rules on eval fixtures
([#244](#244))
([cf87c36](cf87c36))
* **lint:** fit the Rust model rules to eval fixtures
([#241](#241))
([3275ce2](3275ce2))
* **lint:** fit the TypeScript model rules on eval fixtures
([#242](#242))
([bb41bb7](bb41bb7))
* **lint:** make bash_local_underscore_prefix an error
([#251](#251))
([cd8c5b8](cd8c5b8))


### Bug Fixes

* **hooks:** let cleanup_worktrees remove worktrees left with only
regenerable outputs
([#235](#235))
([a25ce5b](a25ce5b))
* **hooks:** raise the model rules subject cap and keep cached findings
under it ([#246](#246))
([a451e93](a451e93))
* **hooks:** show each Stop model-rule finding once per session
([#252](#252))
([49cd6f9](49cd6f9))
* **hooks:** skip commits already on the default branch in model rules
([#247](#247))
([3df49a2](3df49a2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: furedea-release[bot] <353651101+furedea-release[bot]@users.noreply.github.com>
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.

fix(hooks): let cleanup_worktrees remove worktrees left with only regenerable outputs

1 participant