Skip to content

feat(agents): hand approved lanes to Herdr task worktree sessions - #184

Merged
furedea merged 2 commits into
mainfrom
feat/herdr-hand-off
Oct 17, 2026
Merged

furedea merged 2 commits into
mainfrom
feat/herdr-hand-off

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

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.

  • Permissions.
    • herdr worktree create, herdr pane split, herdr agent start, and herdr agent prompt move 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.
  • Allowed guard. herdr is governed like gh. Only these forms pass:
    • reads;
    • worktree create without --trust-repository;
    • pane split without --env;
    • agent start <name> --kind claude|codex --pane <id>;
    • agent prompt <name> <text>.
  • Forbidden rule. Arguments after -- on agent start are denied, since they could switch off the child's sandbox, hooks, or approvals.
  • Ownership (hooks/lib/herdr_ownership.py).
    • The verification hook records the names this session starts. agent prompt passes only for those names.
    • A name another live agent holds is not claimed. Herdr is queried, and if it cannot be reached, the claim asks.
    • Pane IDs, run-time targets, and agent rename ask.
  • Skills.
    • 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.
  • ADR-0037 records the boundary.

Refs #181

Verification

  • uv run --frozen pytest tests: 1488 passed. The 3 errors in tests/hermes/test_hermes_gateway.py also occur on main.
    • The new ownership contracts use a fake herdr. They cover starting then prompting, another name, a pane ID, a run-time target, a held name, another session, and rename.
  • ruff, ty, and lefthook pre-commit passed.
  • Live hand-off check after switch is pending.

🤖 Generated with Claude Code

furedea and others added 2 commits October 17, 2026 19:12
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]>
@furedea
furedea merged commit 0776581 into main Oct 17, 2026
11 checks passed
@furedea
furedea deleted the feat/herdr-hand-off branch October 17, 2026 10:22
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]>
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.

1 participant