Skip to content

fix(hooks): report why a merged branch's worktree is kept - #184

Merged
furedea merged 1 commit into
mainfrom
fix/report-kept-worktree-reason
Nov 12, 2026
Merged

furedea merged 1 commit into
mainfrom
fix/report-kept-worktree-reason

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

概要

cleanup_worktrees.py は,PR がマージ済みのブランチの worktree が安全確認に落ちると何も出力せずに残していた.落ちた条件を keep worktree <path>: <理由> として出す.

  • worktree_is_clean を worktree_blocker に改名し,真偽値ではなく理由(または None)を返す.判定そのものは変えず,fail-closed のまま
  • 理由: .git ファイルと admin dir の不一致,commondir・gitdir の不一致,config.worktree の存在,submodule entry,uncommitted changes,admin dir の未登録・読み取り不可
  • 未マージの worktree は従来どおり無出力
  • 既存の不具合も修正: ignored files の分岐が kept リストを上書きし,先に積んだ keep 行を落としていた

テスト

  • tests/hooks/test_cleanup_worktrees_keep_reason.py を先に書いて失敗を確認し,実装で通した(ファイル長の制約のため新規ファイル,related_test_extensions.json に登録)
  • ruff,ty,vulture,pytest(4763 件)がローカルで通過

Closes #183

🤖 Generated with Claude Code

cleanup_worktrees skipped a merged branch's worktree silently when the
safety check failed. worktree_is_clean becomes worktree_blocker and returns
the failed check as a reason, which cleanup reports as
`keep worktree <path>: <reason>` beside the ignored-files line. Decisions
stay fail-closed and unmerged worktrees stay silent.

Also stop the ignored-files branch from overwriting the list of kept lines,
which dropped earlier keep reasons.

Closes #183

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 12, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-12T07:39:55.998534Z c49f56e 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

No blocking findings (0 × P0/P1, 0 × P2/P3).

Checked:

  • The worktree_is_clean → worktree_blocker / _registration_blocker split keeps the same checks in the same order. Every path that used to return False now returns a non-None reason, and OSError while reading commondir/gitdir still fails closed. Moving the config.worktree exists() check out of the try doesn't change behavior.
  • keep_reason runs irreplaceable_ignored_paths only after the blocker check passes, the same as before. It also fixes the earlier walrus bug, where kept := irreplaceable_ignored_paths(...) overwrote the accumulated kept list.
  • Unmerged worktrees and the primary/current worktrees are still skipped silently. Exceptions from run still reach sweep's skip line.
  • New tests cover each reason string, the unmerged silent case, and the case where several keep lines come before an ignored-files line. The isolation tests were updated for the rename.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: c49f56e162

ℹ️ 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 5164b3a into main Nov 12, 2026
27 checks passed
@furedea
furedea deleted the fix/report-kept-worktree-reason branch November 12, 2026 07:54
furedea pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.3](v0.1.2...v0.1.3)
(2026-11-12)


### Bug Fixes

* **hooks:** report why a merged branch's worktree is kept
([#184](#184))
([5164b3a](5164b3a))

---
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>
furedea added a commit to furedea/dotfiles that referenced this pull request Nov 12, 2026
…463)

agent-config を v0.1.3,agent-harness を v0.9.13 に更新し,片付けスクリプトの修正と Pi の srt
設定の修正を取り込む.

| 入力 | 変更前 | 変更後 |
| --- | --- | --- |
| agent-config | `0638e4b` | `9e2843c`(v0.1.3) |
| agent-harness | `37de3ac` | `b365277`(v0.9.13) |

| 主な変更 | 中身 |
| --- | --- |
| furedea/agent-config#184 | `cleanup_worktrees.py` がマージ済みブランチの worktree
を残すとき理由を1行出す.残す理由の行が後続の worktree で消える不具合も修正 |
| furedea/agent-harness#237 | Pi の srt 設定の Nix ソケットを1回だけにする.sidecar・Pi
設定生成の失敗メッセージに操作を含める.PATH の srt に依存しないテスト |

## 検証

- [x] `nix build .#darwinConfigurations.mba.system` が成功
- [x] 生成された `sandbox_policy.json` の `allowUnixSockets` が
`["/nix/var/nix/daemon-socket/socket"]` の1件(`37de3ac`→`1ccafe0` 時点で確認)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Report why cleanup_worktrees keeps a merged branch's worktree

1 participant