Repository navigation
feat(hooks): let the parent run cleanup_worktrees.py after merge - #300
Merged
Merged
Conversation
This was referenced Oct 22, 2026
Add exact sandbox exclusions and a guard allow rule for the bare call and --dry-run only, and document the post-merge cleanup step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Allow only the absolute call form, ask on newline or carriage return, and treat interpreter and shell wrappers as cleanup invocations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…workspaces Write the cleanup and Codex companion exclusions as ~/ paths, accept the tilde and expanded forms in the guard, and close a primary Herdr workspace that an agent session created once no linked worktree or agent remains. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… closed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…path Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…orktree Take each worktree and its admin dir from the primary's porcelain list, run git against a lane with explicit --git-dir/--work-tree from the primary, disable fsmonitor and hooks, and skip worktrees whose .git file points elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…T_ env Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Reject primaries inside sandbox-writable locations, require a real .git directory, cross-check gitdir links, and remove lane worktrees with the isolated git call while herdr only closes the workspace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ry lives Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
furedea-agent
Bot
force-pushed
the
feat/cleanup-after-merge
branch
from
October 22, 2026 18:27
b5d467f to
9880e4b
Compare
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
ユーザーがマージしたあと,親セッションが
~/.claude/hooks/cleanup_worktrees.pyを実行して,マージ済みの worktree とブランチを片付け,mainを fast-forward する.herdr worktree removeで手作業で消すと,ブランチが残り,次の掃除の対象からもリポジトリが外れるため,それをやめる.agents/claude/settings.json:sandbox.excludedCommandsに絶対パスの 2 件(引数なし,--dry-run)だけを追加.ワイルドカードなしの完全一致.--dry-runだけを確認なしで許可する.追加引数,連結,パイプ,リダイレクト,ラッパー経由は従来どおり確認になる.branches.md,herdr-delegation/SKILL.mdを更新.変更前後
.gitに書けない)--dry-runのみ--dry-runは許可,それ以外は従来どおりherdr worktree removecleanup_worktrees.pyを実行受け入れ条件
excludedCommandsに 2 件だけ追加されている(テストあり)--dry-runを許可する(テストあり)branches.md,herdr-delegationが更新されているlefthook run pre-commit --all-filesとpytest tests/agentsが通る既知の制限
primary ワークスペースを閉じる判定は,セッションの所有権 record を信頼する.state ディレクトリは sandbox 内から書けるため,偽の record を置かれると,エージェントが動いていない user のワークスペースを閉じさせられる可能性がある.閉じられるのは,エージェントが動いていないワークスペースだけである.既存の
herdr workspace closeの所有権判定と同じ信頼モデルとして受け入れる.レーン worktree の
.gitや config に仕込まれたコマンド(core.fsmonitorなど)は,スクリプトが primary 側の admin dir を明示して git を実行するため,動かない.primary の信頼判定は,sandbox で書き込める場所(
sandbox.filesystem.allowWrite,/tmp,TMPDIR,~/.herdr/worktrees)の外にあり,.gitが実ディレクトリのものに限る.設定ファイルを読めないときは,レーン由来の primary を飛ばし,呼び出し元自身のリポジトリだけを掃除する.次の場合は primary と判定されず,掃除の対象から外れる(受け入れる):
.gitがファイルの primary(separate-git-dir),サブモジュール内の cwd.primary 自体が
extensions.worktreeConfig=trueの場合,競合して書き換えられたconfig.worktreeの読み込みは防げない.どのリポジトリもこれを有効にしておらず,sandbox.filesystem.denyWriteが~/**/.git/worktrees/*/config.worktreeへの書き込みをすでに塞いでいる(fix(sandbox): deny writes to every repository's git hooks and config #298)ため,受け入れる.Closes #299
🤖 Generated with Claude Code