Repository navigation
feat(hooks): sweep merged T3 Code lane worktrees like Herdr ones - #266
Conversation
T3 Code creates lane worktrees under ~/.t3/worktrees/<repo>/<branch-prefix>-<hash>, the same two-level layout as Herdr. The session-start sweep now discovers repositories from both roots and treats both as lane-writable, so a primary checkout planted under either is never trusted. Removal conditions are unchanged. Refs #264 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Review summary: no findings. I checked three things in
The tests cover the new T3 behaviour. I didn't run them. 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 171f242880
ℹ️ 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".
A symlink planted at <lane root>/<repo> or <lane root>/<repo>/<lane> resolved to a trusted repository and made the sweep run gh and cleanup there. Lane discovery now accepts only real directories at both levels. Refs #264 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
Review summary (read-only): no blocking findings.
I didn't run the tests. The PR reports a full pass. |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
CI runners have no git identity, so committing inside the cloned repository failed. A new branch at the clone's HEAD is enough to stand in for merged work. Refs #264 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
Review summary: I found no correctness or security issues that should block this PR, so I'm leaving no inline comments. What I checked:
Accepted trade-off, already documented in the PR body: this hook also deletes the merged branch, so T3 can't recreate that checkout. It also doesn't protect an active T3 session in a worktree other than the caller's. Those are the conditions the Herdr sweep already applies, so I'm not flagging them. I only read the diff and the surrounding code. I did not run the tests. 🤖 Generated with Claude Code |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 23fac6b196
ℹ️ 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".
…ions (#268) ## 概要 `herdr-delegation` の手順を引き継ぎ,道具に依存しない `delegation` Skill を作った.本体は操作名(Start・Prompt・Wait・Read・Close・Clean up)だけを使い,`t3 thread` の具体的な操作は `references/t3.md` に置く.T3 Code を既定の transport とし,Herdr は fallback ではなく,利用者が明示したときだけ使う非推奨の道具にした.T3 が使えないとき(たとえば #265・#266 が入る前)は lane を始めず,理由を利用者に報告する.transport を勝手に切り替えない.`herdr-delegation` は description と先頭の 1 行で,利用者が明示したときだけ使うと示した(本文は変えていない). Refs #264(計画:#264 (comment) の `delegskill` lane) ```mermaid flowchart LR D["development-cycle<br/>branches.md"] -- "T3 があれば" --> S["delegation/SKILL.md<br/>(操作名だけ)"] D -- "T3 がなければ" --> X["lane を始めず報告"] U["利用者が Herdr を明示"] -.-> H["herdr-delegation(非推奨)"] S --> T["references/t3.md<br/>t3 thread の操作・guard の契約"] S -. "Herdr 削除時に移す先" .-> R["references/herdr.md"] ``` ## 変更前後 | | 変更前 | 変更後 | | -------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | 委譲の Skill | `herdr-delegation`(`herdr` の操作が本文に) | `delegation`(本文は道具に依存しない).`herdr-delegation` はそのまま | | 道具の操作の置き場所 | Skill の本文 | `references/<transport>.md`.reference のない道具は `development-cycle` が示す Skill | | lane の渡し方 | Herdr が使えれば Herdr | 既定は T3.T3 が使えなければ lane を始めず報告.Herdr は利用者が明示したときだけ | | `branches.md` | Herdr の手順と共通の規則が混在 | 共通の lane 規則と `## Herdr on Explicit Request` 節に分けた(`herdr` のコマンドの文面は変えていない) | ## 変更 - `agents/skills/delegation/SKILL.md`(新規):受け手の選び方(Codex のコマンドの規則を含む),brief,レビューの割り当て,実装の割り当て,待機と照合,後片付けを `herdr-delegation` から引き継いだ.道具の固有の記述は操作の表(Start・Prompt・Wait・Read・Close・Clean up)に置き換えた.道具の選び方は「利用者の指定,なければ `development-cycle` の Branches and worktrees」,reference は「`references/` の道具名のファイル,なければ `development-cycle` が示す Skill」と書いたので,Herdr の操作を後で `references/herdr.md` に移しても `SKILL.md` は変えなくてよい. - `agents/skills/delegation/references/t3.md`(新規):前提(`t3 thread list`,1 回の Bash に `t3 thread` 1 つ,sandbox の `EPERM`),受け手(`claudeAgent`・`codex`.Antigravity は受け手にしない,google-antigravity/antigravity-cli#1493),guard の契約(#265 の挙動を契約として記述),操作(Start・Wait・Prompt・Read・Close・Clean up と `--wait` の終了コード 0・1・2). - `agents/skills/development-cycle/SKILL.md`:委譲先を `delegation` にし,Herdr は利用者が明示したときだけ使う非推奨の道具として `herdr-delegation` を残した. - `agents/skills/development-cycle/references/branches.md`:上の表のとおり. ### T3 の操作で選んだ形と理由 - **Start は `--wait` なしの `--json` を前景で実行**:#265 の guard は `start --json` の stdout の `threadId` を PostToolUse で記録する.Claude は終了コードが 0 でない Bash に PostToolUse を出さないので,`start --wait --json` が 1・2 で終わると記録されず,以後の `send` が確認になる(#265 の申し送り). - **Wait は `t3 thread show --json` の polling**:`send` は lane に turn を足すので待機に使わない.`show --json` を 1 回ずつ独立した呼び出しで実行し,`thread.status`・`activeRunId`・`latestRunId`・`pendingRequestCount` で判断する.間は `t3` を含まない background の `sleep 300`.フィールドと値は T3 0.1.10 の `packages/contracts/src/orchestratorMcp.ts`(`OrchestratorMcpThreadDetail`)と `orchestrationV2.ts`(`OrchestrationV2RunStatus`),`apps/server/src/cli/thread.ts`(`threadShowCommand`)で確認した.`t3` を loop や Monitor に入れると 1 つの `t3 thread` コマンドでなくなり sandbox の中で失敗するので使わない. - **回答待ち(`pendingRequestCount` > 0)**:人が T3 の画面で答え,親は答えない.親はどの lane が待っているかを伝え,polling を続ける. - **model**:`claude-sonnet-5-5`(`claudeAgent`),`gpt-6.1-sol`(`codex`).T3 0.1.10 の `apps/server/src/provider/model-manifest.json` で 2026-11-21 に確認.CLI に model を一覧するコマンドはない. - **Close**:CLI に thread を止める・アーカイブするコマンドはないので,人が T3 の画面でアーカイブする. - **Clean up**:`cleanup_worktrees.py` が `~/.t3/worktrees` を Herdr と同じ条件で消す,と契約として書いた(実装は `t3cleanup` lane). ## テスト - [x] `uv run --frozen pytest -q`:6328 passed,2 skipped(レビュー修正後に `tests/test_workflow_skill_layout.py tests/skills` を再実行:67 passed) - [x] `uv run --frozen pytest -q -m integration tests/test_workflow_skill_layout.py`:4 passed(Claude と Codex の両方で `delegation` の name と description が描画される) - [x] `agent-harness generate-skills --provider claude|codex`:両方に `delegation/SKILL.md` と `delegation/references/t3.md` が出る - [x] `agent-harness install` → `agent-harness verify`:成功.`.claude/skills/delegation` が入る - [x] `dprint check`(変更した 4 ファイル),pre-commit(ls-lint ほか),commitlint:成功 - [ ] T3 の thread で 1 lane を実際に動かす確認:計画どおり全 lane の merge 後に行う ## レビューへの対応 - [x] T3 を guard・cleanup より先に選び得る(P2,2 件):T3 を選ぶ条件を「sandbox の中で `t3 thread list` が通る」にした(c70df2bc). - [x] Start の provider が `claudeAgent` 固定(P2):`--provider <provider>` にし,選んだ受け手に合わせると書いた. - [x] effort を設定できない(P3):`branches.md` の規則を「設定できるときは medium」にし,`t3.md` に 0.1.10 の制限を書いた. - [x] 終了コード 2 の後の Wait が turn を積み上げる(P3):再び Wait する前に Read で確認し,Wait は 1 回だけにした. - [x] Claude Code が background の待機を止めた場合(P2,2 回目):0・1・2 以外の終了は待機の終わりとして,Read で状態を見てから Wait を 1 回だけ出す.brief は送り直さない(73db7b49). - [x] #266 より先に merge された場合の cleanup(P2,2 回目):実装の lane を T3 に渡すのは,インストール済みの `cleanup_worktrees.py` が `~/.t3/worktrees` を扱うときだけにし,それまでは実装の lane を始めず報告する(4 回目の指示で Herdr への切り替えをやめた). - [x] 計画レビューで worktree を作らない Start(P2,2 回目):`--worktree` と `--branch` を付けない形を足した. - [x] 待機の `send` が turn を積む(P2,3 回目):待機を `t3 thread show --json` の polling に作り直した(b330a65d). - [x] 初回利用で model slug を決められない(P2,3 回目):具体的な slug と確認日を書いた. - [x] `grep -F .t3/worktrees` がコメントにも一致する(P3,3 回目):`^LANE_WORKTREES = ` の定数の行に一致する検査にした. - [x] guard の契約を守る hook がこの PR にない(P2,3 回目):コードは変えず Limits に記録した(下記). - [x] 計画レビューの条件が `t3.md` と食い違う,provider instance を選ばない(P2,5 回目,2 件):P1 だけを直す回なので変えず,理由を返して resolve し,Limits に記録した. - [x] Prompt の後の待機が前の turn の状態を読む,background の作業の後の run を待たない(P2,4 回目,2 件):利用者の判断で待機の手順は変えず,計画の「T3 の thread で 1 lane を実際に動かして確認」に回した.`activeRunId`・`latestRunId` の動きを確かめてから別の PR で直す. ## 計画との差 - なし.Skill の描画は `agents/skills/` のディレクトリを自動で拾うので,`agents/skill_rendering.json` や Nix の変更は要らなかった. <details> <summary>範囲・前提・限界</summary> - merge の順序:#265(guard)と #266(cleanup)の後に merge するのがよい.T3 を選ぶのは `t3 thread list` が sandbox の中で通るとき(guard と同時に入る `excludedCommands` の `t3 thread *` が要る)だけなので,先に入っても T3 は選ばれず,lane を始めずに報告する.実装の lane は,インストール済みの `cleanup_worktrees.py` が `~/.t3/worktrees` を扱うまで(#266)T3 に渡さないので,cleanup の順序にも依存しない. - `references/t3.md` の `t3 thread` のコマンドは fenced の bash block ではなく inline code にした.`tests/skills/test_skill_commands.py` は skill の bash block を hook で判定し,guard が入るまで `t3 thread` は未登録になるため.期待値ファイルはこの lane の範囲外. - 他の lane のファイルで `herdr-delegation` を指しているもの(報告のみ,未変更):`docs/DESIGN.md`,`docs/DESIGN_ja.md`(`t3adr` lane).`docs/adr/0023_*`・`0024_*` は過去の決定の記録なので変えない. - 未確認:`--worktree origin/<base>` のような remote-tracking ref を T3 が受けるか(help は「branch, tag, or commit」).thread が run のない状態で `status` が `idle` になるか直前の run の状態になるかは実機で見ていない(`activeRunId` が `null` を終了の条件にした).インストール済みの 0.1.10 の CLI に effort を指定する `--option` はない. - Limits:`references/t3.md` の Guard Contract を守る hook は #265 で入り,この PR には含まれない.T3 を選ぶ条件(sandbox の中で `t3 thread list` が通る)は #265 の `excludedCommands` がないと満たされないので,それまで T3 は選ばれず,lane を始めずに報告する.Antigravity を受け手にしない規則の強制も #265 の guard による. - Limits:Prompt の直後の `show` が前の turn の状態を返す場合と,background の作業の後に起きる run を,今の待機は区別しない(実機確認に回した,上記). - Limits:`branches.md` の手順 3 は計画レビューにも cleanup の条件をかけるので,#266 が入るまで計画レビューも始めずに報告する(`t3.md` は計画レビューに cleanup の条件をかけない).条件の検査は #266 の定数 `LANE_WORKTREES`(その diff で定義を確認済み)に依存するので,#266 はこの名前を保つ必要がある. - Limits:`--provider` は `claudeAgent`・`codex` の既定の instance だけを使う(#265 の guard の方針).それらが無効な環境では Start が失敗し,利用者に報告する. - Limits:polling の間隔(`sleep 300`)は固定で,lane の終了から最大 5 分遅れて気づく. - Limits:`branches.md` の手順は T3 が使えるかを先に見るので,利用者が Herdr を明示しても,その手順だけを読むと T3 が選ばれる(P2,最終回).`delegation/SKILL.md` は明示された transport を使うと書いているので,そちらに従う.手順の並びは後の PR で直す. - Limits:Wait の `--messages 1` では,最新のメッセージが assistant の返信でないとき返信が出力に入らない(P3,最終回).待機の手順と同じく,T3 の実機での確認に回す. - 範囲外:guard・cleanup の実装,ADR,Herdr と `herdr-delegation` の削除(非推奨にしただけで動作は残す). - 脅威モデル:計画のとおり.lane は親の session に送らない,`send` は自分が起動した thread だけ,を Skill に書き,強制は guard(#265)が行う. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
🤖 I have created a release *beep* *boop* --- ## [0.4.0](v0.3.1...v0.4.0) (2026-11-21) ### Features * **hooks:** add the Antigravity hook adapter ([#263](#263)) ([22b5980](22b5980)) * **hooks:** guard t3 thread so lanes start only on Claude or Codex ([#265](#265)) ([aa0de7a](aa0de7a)) * **hooks:** sweep merged T3 Code lane worktrees like Herdr ones ([#266](#266)) ([8c730aa](8c730aa)) * **skills:** add a tool-neutral delegation skill with T3 Code operations ([#268](#268)) ([dc2c3cc](dc2c3cc)) --- 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>
cleanup_worktrees.pyが Herdr の lane(~/.herdr/worktrees)に加えて,T3 Code の lane(~/.t3/worktrees)も merge 後に片付けるようにします.消す条件は Herdr と同じで,Herdr の動作は,置き場内のシンボリックリンクを辿らなくなった点を除いて変わりません.T3 自身の自動削除とは消す条件が同じ向きで,同時に動いても失敗は repository 単位の
skip行になるだけです(下記).Refs #264
計画:#264 (comment)
~/.herdr/worktrees/*/*~/.herdr/worktrees/*/*と~/.t3/worktrees/*/*~/.herdr/worktrees配下untrusted_locations()~/.herdr/worktreesを含む~/.t3/worktreesも含む<repo>や<repo>/<lane>がシンボリックリンクのとき検証
~/.t3/worktreesに置かれた偽の primary を信頼しない,本番の untrusted locations に~/.t3/worktreesが入る)uv run pytest -q tests/hooks/test_cleanup_worktrees*.py:143 passed(修正後)uv run pytest -q(全体):6329 passed,2 skippeduv run ruff check,uv run ruff format --check,uv run ty check:pass(pre-commit も pass)`~/.t3/worktrees` の構造と T3 の自動削除との関係
構造:手元の
~/.t3/worktreesは空(2026-11-21,読み取りのみのls).T3 のソースapps/server/src/vcs/GitVcsDriverCore.ts(createWorktree)では<worktree 置き場>/<repo 名>/<branch の先頭 23 byte(/ は -)>-<sha256(common dir と branch) の先頭 16 桁>[-2, -3 …].worktreesDirectory.tsのisManagedWorktreePathも置き場から 2 階層を T3 管理の worktree とみなすため,Herdr と同じ*/*で見つかる.T3 の自動削除(docs/user/project-settings.md「Storage cleanup」)との関係:
git worktree removeが失敗しても例外は repository 単位で捕まえskip <primary>: …を出すだけで,session は止まらない(hook は常に 0 で終わる).範囲外・制限:
~/.t3/worktreesのみ.~/.t3)から変えた場合も見ない.~/.t3/worktrees・~/.herdr/worktrees自体のシンボリックリンクも拒否する)は修正しない:root は lane の sandbox から書けず,別ドライブへのリンクは正当な使い方で,リンク先で受理されるのは登録と書き込み不可を確かめた実在の primary だけ(消す条件も同じ).workspace closeに当たる後始末はなく,thread は T3 側に残る(T3 の UI で消す).🤖 Generated with Claude Code