Repository navigation
feat(agents): hand approved lanes to Herdr task worktree sessions - #184
Merged
Merged
Conversation
After plan approval each lane runs in a Herdr task worktree with its own Claude or Codex session. Creating the worktree or pane, starting the agent without extra arguments, and prompting an agent the session started now pass; ownership is recorded per session and a name another agent holds is not claimed. Agent arguments after -- are denied; repository trust, pane environments, other kinds, renames, and existing panes still ask. Refs #181 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #181 Co-Authored-By: Claude Opus 5.5 <[email protected]>
furedea
added a commit
that referenced
this pull request
Oct 17, 2026
…rt (#185) PR 2 of #181. Merged task worktrees and local branches are removed without a person running `git branch -D`. - **`agents/hooks/cleanup_worktrees.py`.** A branch goes only when both hold: - a merged pull request's head is exactly its tip; - its worktree is clean. Squash merges therefore count as merged, while later or uncommitted work stays. The primary checkout, the caller's own worktree, and `main`/`master` are never touched. An open Herdr workspace is closed with its checkout (`herdr worktree remove`), and other worktrees use `git worktree remove`. - **Scope.** It sweeps the caller's repository and every repository with a Herdr task worktree under `~/.herdr/worktrees`. A lane merged in one repository therefore goes at whichever session starts next. A failure in one repository skips only that repository. - **Triggers.** - The Claude SessionStart hook runs it asynchronously, so start-up never waits on GitHub. Hooks run outside the sandbox, so agents still never get `-D`. - `cleanup_worktrees.py --dry-run` reports what would go. - It uses only git, gh (one `gh pr list --state merged` call), and Herdr. No gh-poi. - **`branches.md`.** Tells agents not to delete merged worktrees by hand. Remote branches: `delete_branch_on_merge` is already on for the active repositories. It is off for `obsidian` (no PRs), `book-agent`, `swe-bench-trial`, `revisiting-pgd-evaluation`, `pairs`, and older learning repos. The agent App token cannot change repository settings, so that is left to the user. Closes #181 ## Verification - `uv run --frozen pytest tests`: 1498 passed. The 3 errors in `tests/hermes/test_hermes_gateway.py` also occur on main. - The new contracts use temporary repositories with fake `gh` and Herdr. They cover: - a merged worktree; - a merged branch without a worktree; - a later commit, a dirty tree, and an open PR, all kept; - the primary and current checkouts, kept; - `--dry-run`; - a Herdr workspace closed with its worktree; - the hook never blocking; - a merged Herdr lane of another repository swept from an unrelated directory. - A dry run on this repository found exactly the two squash-merged branches from #183 and #184. - The Herdr hand-off from PR 1 was checked live: worktree, agent start, and prompt ran with no permission prompt. - ruff, ty, deptry, vulture, and lefthook passed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
PR 1 of #181. After plan approval, each lane is handed to a Herdr task worktree and a Claude or Codex session started there, without prompts.
herdr worktree create,herdr pane split,herdr agent start, andherdr agent promptmove to allow.send-keys,send-text,pane run, and closing workspaces still ask. Herdr runs outside the sandbox, so keystrokes to an existing pane run there too.herdris governed likegh. Only these forms pass:worktree createwithout--trust-repository;pane splitwithout--env;agent start <name> --kind claude|codex --pane <id>;agent prompt <name> <text>.--onagent startare denied, since they could switch off the child's sandbox, hooks, or approvals.hooks/lib/herdr_ownership.py).agent promptpasses only for those names.agent renameask.branches.md: the hand-off steps after approval.issue-workflow: plans split work into lanes and stop for approval. Approval covers commits, pushes, and PRs, not merging.herdr-delegation: covers approved lanes.Refs #181
Verification
uv run --frozen pytest tests: 1488 passed. The 3 errors intests/hermes/test_hermes_gateway.pyalso occur on main.herdr. They cover starting then prompting, another name, a pane ID, a run-time target, a held name, another session, and rename.🤖 Generated with Claude Code