Skip to content

feat(delegation): offer herdr-core terminals as an alternative lane transport - #281

Merged
furedea merged 13 commits into
mainfrom
refactor/delegate-through-herdr-core
Nov 28, 2026
Merged

furedea merged 13 commits into
mainfrom
refactor/delegate-through-herdr-core

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

lane の transport に herdr-core(hc)を代替経路として追加します.T3 Code は既定の transport のまま残します.
ユーザーが Herdr アプリや hc を求めたとき,または T3 Code を使えないときに,lane を Herdr アプリ(デスクトップ・iPhone)から見て承認・応答できるようにするためです.
判断事項:下の「未確認事項」(実機で未検証の点)と,worktree 作成に Herdr TUI の herdr worktree create を使う設計.

Closes #280

flowchart TD
  S{lane を起動} -->|ユーザーが Herdr アプリ / hc を指定| H[herdr-core]
  S -->|指定なし| T{T3 Code を使える?}
  T -->|はい| T3[T3 Code thread(既定)]
  T -->|いいえ| A{herdr-core を使える?<br/>Herdr アプリ起動済み}
  H --> A
  A -->|はい| HC[hc run で hc terminal]
  A -->|いいえ| X[lane を起動せず理由を報告]
Loading
Before After
既定の transport T3 Code T3 Code(変更なし)
代替経路 なし(T3 不可なら停止) herdr-core: herdr worktree create の後に hc run --bg --no-parent --json --name --cwd --label ... claude|codex "<brief>"
前提条件(hc) — Herdr アプリが起動していること.hc は core が無いと起動し,その core は呼び出し元の環境を引き継ぐため,最初の hc 呼び出しの前にユーザーに確認する
待機(hc) — hc wait <address> --timeout 1800 --json の turn/status で判定
lane → 親 送信しない 同じ(<hc> タグは検証不能なため,--no-parent で note も止める)
sandbox 除外 t3 thread * t3 thread * と hc *
guard(hc) — hc run は claude/codex のみ.許可外のエージェントオプションは deny.他プログラム・テンプレート・--on・未知オプション・1 語の brief(claude update など)は ask
所有権(hc) — 自セッションの hc run --json が出した address のみ send/kill/rm 可.毎回 hc get で created_ms を照合する
hc run --cwd — このセッションの checkout か,このセッションが作った lane worktree 内の絶対パスのみ
Herdr TUI ペイン 非推奨・明示要求時のみ 同じ(T3 や herdr-core が使えないときの代替にもしない)
ADR ADR-0028 accepted ADR-0028 accepted のまま,ADR-0030(herdr-core を代替経路として追加)accepted

検証

  • uv run pytest: 6611 passed, 2 skipped(T3 のテストを復元し,tests/hooks/test_hc_terminal.py と tests/hooks/test_hc_ownership.py を追加)
  • ruff check / ruff format --check / ty check
  • bats tests/bootstrap_server.bats tests/codex/execpolicy.bats
  • T3 部分(t3_thread.py,t3_ownership.py,references/t3.md,cleanup の ~/.t3/worktrees,permissions,settings,hooks)は origin/main と同じ内容に戻した
  • CI(push 後に再実行)

レビュー対応

  • P1 --cwd 無制限,P1 primary workspace を root とみなす(Codex): 修正.
  • P2 core 再起動後の address 再利用(Claude),P2 --cwd 省略時の継承(Codex): 修正.
  • P2 移行中も ~/.t3/worktrees を掃除する(Codex): T3 を残すことになったため,origin/main の掃除対象がそのまま残る.
  • P3 1 語のサブコマンドが brief として通る(Claude): 修正(ask).
  • P2 hc ls が停止中の core を起動する(Codex): Herdr アプリの起動を前提条件として references/hc.md と ADR-0030 に明記.
未確認事項・前提・範囲
  • この環境の sandbox からは hc が core lock を開けず(Operation not permitted),実機で hc run --bg --json の出力,hc wait の挙動,Herdr アプリでの表示は確認できていない.仕様は hc --help,hc --skill(0.1.22),herdr-core の schema/hc.openrpc.json と AGENTS.md,herdr-app の defaults/AGENTS.md から読んだ.
  • macOS では hc server status も含め,どの hc コマンドも core が無ければ起動する(herdr-core platform/unix.rs の may_autostart,status_may_start_core).起動せずに稼働を確かめる hc コマンドは無い.
  • Claude Code 2.1.295 以降と Codex 0.163 以降が OSC 7501 を出すことは stablyai/orca の support matrix(2026-11-17)による.
  • worktree 作成は Herdr TUI の herdr worktree create を使う(hc に worktree コマンドが無く,sandbox は他リポジトリの .git/worktrees に書けないため).
  • 範囲外:dotfiles での herdr-core の導入と sandbox 設定の配布,Herdr TUI の削除.

🤖 Generated with Claude Code

@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-28T14:28:49.734010Z
We couldn’t complete this review. Comment @codex review to try again.
fae28c6 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.

Comment thread agents/hooks/lib/hc_ownership.py Resolved
@github-actions

Copy link
Copy Markdown

Review summary

I found one P2 problem (inline comment on agents/hooks/lib/hc_ownership.py) and no P0 or P1 problems. I did not run the code or the tests. This is a read-only review of the diff, and hc itself has not been run against a real core, as the PR description says.

P2. Terminal addresses recorded in hc_terminals.json are trusted for the whole session. The docs say an address is valid only "for the core's life". After a core restart, a recorded address such as t7 may point to someone else's terminal, and hc send, hc kill and hc rm on it would then be allowed without a prompt. I could not confirm that addresses are reused, so the comment suggests recording a core identifier or enforcing hc get before those calls.

What I checked and found fine

  • The deny and ask paths in hc_terminal.py handle the bypasses I tried:
    • agent options outside the allowed set, including = forms, a path-qualified agent, wrappers and bash -c;
    • unknown hc run options such as --on and --template;
    • dynamic and spreading words;
    • duplicate options;
    • send --force;
    • lines holding several commands.
  • confirm records an address only from one plain, literal hc run --json call that succeeded.
  • The hooks.json filter Bash(hc run *), the sandbox exclusion hc *, the permission prefixes, and the swap from t3_ownership to hc_ownership in verification_session.py are consistent with each other. The tests cover them.
  • No stale T3 references remain outside the changelog and the superseded ADR-0028.

P3, no action required. hc read, hc get and hc wait are allowed for any terminal, so a lane's parent can read the screen of a terminal it did not start. hc run --cwd is also not restricted. The old t3 thread show was just as open, and test_hc_terminal.py expects this behavior. If this is not intended, consider an ownership check on those reads.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2b95d21e4f

ℹ️ 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".

Comment thread agents/hooks/lib/hc_terminal.py Resolved
Comment thread agents/hooks/cleanup_worktrees.py Resolved
@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/hc_ownership.py Resolved
@github-actions

Copy link
Copy Markdown

Review summary

I reviewed the new hc_terminal.py and hc_ownership.py guards, the permission and hook wiring, and the new tests. The T3 removal looks clean: nothing else imports t3_thread or t3_ownership.

Findings

  • P2: hc run without --cwd skips the containment check (inline comment on hc_ownership.py). The lane then starts in the inherited cwd, and the new tests don't cover that case.

Notes (no action required)

  • hc get, read, wait and ls --all are allowed on any terminal, not only ones this session started. Ownership applies only to send, kill and rm. That matches the ADR, but it means a lane can read the user's or parent's terminal screens. Consider saying so explicitly in the ADR.
  • The PR says hc output was not verified on a real machine: created_ms, address and the hc get --json shape come from the spec only. If hc get can't run from the hook's environment, hc send, hc kill and hc rm will always ask. That fails safe, but check it on a real machine before relying on it.

No P0 or P1 issues found.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1921ad3dd0

ℹ️ 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".

Comment thread agents/hooks/lib/hc_terminal.py Resolved
@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/hc_ownership.py Resolved
@github-actions

Copy link
Copy Markdown

Review summary

I read the whole diff, including the new hc_terminal and hc_ownership hooks and their tests. I did not run the tests, and I could not check hc behaviour on a real machine.

Findings

  • P1 (agents/hooks/lib/hc_ownership.py): hc run --cwd containment trusts every entry in the session's recorded Herdr workspaces. That includes entries from herdr workspace create --cwd <anything>, which is allowed without a prompt and not restricted. A session can therefore open a workspace on $HOME or another repo and then start a lane rooted there with no approval. Only entries from worktree create should count as roots. A regression test is needed too.

What looked fine

  • The agent-option deny list, the hc run grammar, the dynamic-word handling and the created_ms re-check before send/kill/rm all held up.
  • The hc permission prefixes and excludedCommands match the tests.
  • The T3 removals are complete: no t3 references are left outside the changelog and ADR-0028.

Not reviewed

  • The "未確認事項" in the PR description (behaviour on a real machine) is outside what I could check read-only.
  • I did not look at the rest of the docs diff.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 05f5e3f992

ℹ️ 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".

Comment thread agents/hooks/lib/hc_ownership.py Resolved
@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/hc_terminal.py Resolved
@github-actions

Copy link
Copy Markdown

Review summary

I found no P0, P1 or P2 issues, and left one P3 as an inline comment.

I read the new hc_terminal and hc_ownership modules, the hook wiring (guard_command, verification_session, hooks.json), the permission rules, and the tests. I did not run the code or the tests.

  • Ownership model: hc_ownership records the address and created_ms from a plain hc run --json. It checks them against hc get before every send, kill or rm. If the output shape differs from what the PR assumes, ownership is never recorded and driving a terminal is refused, so it fails closed.
  • --cwd confinement: --cwd must be absolute and must resolve inside the session's checkout or a worktree the session created. Spread, dynamic or valueless forms are refused or sent to review.
  • P3 (inline): a single positional passes as "one brief", so a one-word subcommand such as claude update also passes. The effect is small.
  • Unverified assumptions: the PR description says hc run --json output, hc wait behaviour and the --no-daemon Codex option were not checked on a real machine. The guard depends on the created_ms and address field names.
  • Not checked: the PR deliberately drops cleanup of ~/.t3/worktrees. Existing T3 worktrees will no longer be swept automatically.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 42eeaf5362

ℹ️ 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 and others added 9 commits November 27, 2026 20:31
Lanes now run in herdr-core terminals started with `hc run`, so every hc
call leaves the sandbox and the guard bounds what it may do: `hc run`
starts only claude or codex with their lane options, and send, kill, and
rm reach only the addresses this session's own `hc run --json` printed.
The T3 thread guard, its ownership record, its sandbox exclusion, its
permissions, and the ~/.t3/worktrees lane root are removed.

Refs #280

BREAKING CHANGE: `t3 thread` commands no longer leave the sandbox or have
permission rules; `hc *` leaves the sandbox instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Herdr app shows herdr-core terminals on the desktop and the iPhone,
so delegation starts lanes with `hc run`, waits on the agents' own OSC
7501 status with `hc wait`, and reads replies with `hc read`. The T3
reference is replaced by references/hc.md, and herdr-delegation now
points at the new flow.

Refs #280

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ADR-0029 supersedes ADR-0028 now that T3 Code is gone, and the design
overview names hc instead of t3 thread.

Refs #280

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…resses

`hc run --cwd` now has to lie in this session's checkout or a lane
worktree it created, because the lane's sandbox is rooted there. A start
records the terminal's creation time beside its address, and send, kill,
and rm ask the core with `hc get` that the address still names that
terminal, since an address is unique only within one core.

Refs #280

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Without --cwd the lane inherits whatever directory the call runs in, which
the ownership check cannot see, so a start without it now asks.

Refs #280

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A session may open a Herdr workspace on any directory, so a recorded
workspace is no evidence that the directory is the session's. Only the
checkouts it created with `herdr worktree create` now count, beside its
own checkout.

Refs #280

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ADR-0029 on main now records leaving session content to atuin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A single word after the agent's options may be a subcommand such as
`claude update` or `codex login` rather than a message.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea-agent
furedea-agent Bot force-pushed the refactor/delegate-through-herdr-core branch from 42eeaf5 to da71266 Compare November 27, 2026 11:40
@furedea

furedea commented Nov 27, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary (read-only, no inline findings)

I read the guard, ownership and hook-wiring changes and the delegation docs. I did not run the test suite.

  • hc_terminal guard: the deny and ask paths are consistent with each other and with the Guard Contract in references/hc.md. I could not construct a bypass through option forms, -- handling, path-qualified hc, dynamic words or duplicate options.
  • hc_ownership: --cwd is confined to the session checkout and the worktrees it created. send, kill and rm need an address recorded from run --json, and the created_ms is re-checked with hc get before each call. Any failure refuses, so it fails closed.
  • Cleanup and permissions: the T3 removal is complete in cleanup_worktrees, hooks.json, settings.json and command_permissions.json.
  • Tests: new coverage exists for both hc_terminal and hc_ownership.

P3 (description only): the PR body says ADR-0029 is accepted, but the added ADR is 0030_hand_approved_lanes_to_herdr_core_terminals.md. 0029 is already taken by the atuin ADR. The in-repo links all say 0030, so the PR description is the only thing to fix.

The unverified-on-device points listed in the PR body (OSC 7501 status, created_ms type) remain assumptions. If created_ms is ever a float, _is_time rejects it and send, kill and rm are refused for every lane. That would be safe, but it would break the workflow.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da71266ab0

ℹ️ 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 and others added 3 commits November 28, 2026 23:12
T3 Code stays the default lane transport, so its guard, ownership
record, sandbox exclusion, permissions, and lane root return, and the hc
checks run beside them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e alternative

The parent uses herdr-core when the user asks for the Herdr app or hc,
or when T3 Code is unavailable. Since every hc command starts a core
that inherits the caller's environment, the Herdr app must be running
before the first hc call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ADR-0028 stays accepted: T3 Code remains the default transport.

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

furedea commented Nov 28, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread agents/hooks/lib/hc_ownership.py Resolved
@furedea-agent furedea-agent Bot changed the title feat(delegation)!: hand lanes to herdr-core terminals and remove T3 Code feat(delegation): offer herdr-core terminals as an alternative lane transport Nov 28, 2026
@github-actions

Copy link
Copy Markdown

Review summary

I found no P0 or P1 problems and left one P3 inline comment. I read the diff only; I did not run the tests or a real hc.

What I checked

  • Run guard. hc_terminal.refusal, objection and read agree on how to split an hc run into hc options and the agent's argv. I found no input where the deny check misses an agent option that the ask path would also miss, apart from cases that still reach the ask or ScopeError path.
  • Terminal ownership. hc_ownership stores each started terminal as an address plus created_ms, and each send/kill/rm re-checks that pair with hc get. An unreachable core, a reused address and a name given in place of an address all refuse.
  • Lane directory. --cwd must be absolute and, after resolve(), inside the session's checkout or a worktree the session created. The new created_worktree flag is saved through _save. entries() keeps unknown keys, so created_worktrees() can read it.
  • Hook wiring. hc was added to LITERAL_PROGRAMS, and the post-tool-use hook and the sandbox exclusion were added. The pre-tool-use hook has no if filter, so it covers hc send, kill and rm.
  • Tests. The new tests cover the grammar, ownership, the directory scope and reused addresses.

Finding

  • P3 (inline, hc_ownership.py:103): the hook's own hc get can start a core with the hook's environment, which references/hc.md says must not happen.

Not a code finding

  • The PR description says all T3 pieces are removed, and the "after" column describes hc run replacing t3 thread start. The diff keeps T3 as the default transport, keeps t3_thread and t3_ownership in the guard, and adds herdr-core as an alternative (ADR-0030). Please update the description to match the diff, or finish the removal.
  • The description lists "未確認事項" (points not checked on a real machine). The guard depends on three of them: that hc run --json prints address and created_ms, that hc get --json returns created_ms, and the kill then rm sequence. A mismatch would make every send/kill/rm ask, which is safe but unusable. Check these against a real hc before merging.

🤖 Generated with Claude Code

@furedea

furedea commented Nov 28, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Review summary (read-only)

No P0–P2 findings, so I posted no inline comments.

Read: the hc_terminal guard, hc_ownership (session records and hc get check), the herdr_ownership created_worktree flag, the hook wiring and permissions, and the docs and ADR. I did not run the test suite or CI.

Checked and found sound:

  • Deny/ask split. refusal hard-denies any unlisted option on a claude/codex argv, including options after the brief. objection asks for everything it cannot read: unknown hc options, --on, templates, other programs, dynamic words, assignments, wrappers, redirects, a path-named hc, and duplicate options. I found no form where an unlisted agent option reaches "allow".
  • Ownership. send, kill and rm need an address recorded from a plain, literal hc run --json and a matching live created_ms. A core that cannot answer, or a malformed response, fails closed. This covers address reuse after a core restart.
  • --cwd. It must be absolute and resolved inside the session root or a worktree this session created. Relative paths, dynamic values and .. escapes are rejected.
  • Pre-existing records. Workspace entries written before this change have no created_worktree key, so they are not treated as lane roots. That is the safe direction.

P3, no action needed:

  • The guard, ownership record and docs assume hc run --json prints top-level address and created_ms. The PR description says this was not checked on a real machine. If the real output is nested, nothing is recorded and every send/kill/rm asks. That is a safe failure, but the lane workflow would not work until the shape is confirmed.
  • hc get, hc read and hc wait are allowed on any terminal, so the parent can read the user's own terminal screens. This looks intended given the docs, but it is a wider exposure than send/kill/rm.
  • A literal hc send <addr> "- item" message starting with - is read as an option and asks. That is safe but may surprise users who send bullet-style messages.

Merge risk is low. Before merging, confirm the real hc run --json output on a machine with the Herdr app running.

@furedea
furedea merged commit e0488ef into main Nov 28, 2026
27 of 29 checks passed
@furedea
furedea deleted the refactor/delegate-through-herdr-core branch November 28, 2026 15:01
furedea pushed a commit that referenced this pull request Dec 1, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.6.0](v0.5.1...v0.6.0)
(2026-12-01)


### ⚠ BREAKING CHANGES

* **settings:** declare the harness protection and the agent GitHub
policy ([#286](#286))

### Features

* **delegation:** offer herdr-core terminals as an alternative lane
transport ([#281](#281))
([e0488ef](e0488ef))
* **settings:** declare the harness protection and the agent GitHub
policy ([#286](#286))
([ac335be](ac335be))


### Bug Fixes

* **hooks:** explain gh asks caused by other commands on the line
([#284](#284))
([16ecae8](16ecae8))

---
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.

feat(delegation): offer herdr-core (hc) as an alternative lane transport to T3 Code

1 participant