Skip to content

feat(hooks): guard t3 thread so lanes start only on Claude or Codex - #265

Merged
furedea merged 7 commits into
mainfrom
feat/guard-t3-thread
Nov 21, 2026
Merged

furedea merged 7 commits into
mainfrom
feat/guard-t3-thread

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

概要

t3 thread を sandbox の外で動かせるようにし,guard が start を --provider claudeAgent|codex の明示時だけ通し,send をこの session が起動した thread にだけ通す.Antigravity を別のエージェントから動かさないことを文書でなくコードで守る.

Refs #264(計画:#264 (comment) の t3guard lane)

flowchart LR
    C["Bash: t3 thread …"] --> F["guard_command.py forbidden<br/>t3_thread.refusal"]
    C --> A["guard_command.py allowed<br/>t3_thread.objection"]
    C --> V["verification_session.py pre-tool-use<br/>t3_ownership.check"]
    R["start --json の stdout"] --> P["verification_session.py post-tool-use<br/>t3_ownership.confirm"]
    P --> S[("session 記録<br/>t3_threads.json")]
    S --> V
Loading

変更前後

コマンド 変更前 変更後
t3 thread start --provider claudeAgent|codex --model M [--title|--worktree|--branch V] [--wait] --json . <message>(行に単独) sandbox 内で EPERM allow(sandbox 外)
上の形で project が . 以外(別プロジェクトのパス・ID),--json なし,パイプや && の中の start 同上 ask
t3 thread start で --provider なし,antigravity,利用者が名付けた instance,大文字違い,2 つ目の --provider が許可外 同上 deny(wrapper・bash -c・パス指定・global option の後ろでも)
--base-dir,T3CODE_HOME=…,未知の option,--,option を値にした形,wrapper 経由,--provider だけで --model なし 同上 ask
展開($(…),$VAR,~)・リダイレクト(<,>,heredoc)を含む行,t3 以外のコマンドを ;・&& で並べた行 同上 ask(行全体が sandbox の外で動くため)
t3 thread list --json | jq . など読み取り専用フィルタへのパイプ 同上 allow
t3 thread send <この session が start した id> <message> [--wait] [--json] 同上 allow
t3 thread send <それ以外の id / $VAR> 同上 ask
t3 thread show <id> [--messages N] [--json],t3 thread list [--project P] [--json] 同上 allow
t3 service … など thread 以外の t3 変更なし 変更なし

変更

  • agents/hooks/lib/t3_thread.py(新規):t3 thread の各 action の文法(値を取る option,flag,位置引数の数)で引数を読み,refusal(forbidden guard で deny)と objection(allowed guard で ask)を返す.provider は ID の完全一致の許可リスト claudeAgent,codex.--x=v の形も読む.
  • agents/hooks/lib/literal_words.py:LITERAL_PROGRAMS に t3 を追加.t3 thread を含む行は allows_literal_rules を満たし,全コマンドが t3 呼び出しか読み取り専用フィルタで,t3 にリダイレクトがないときだけ通す.
  • agents/hooks/guard_command.py:行全体を見る事前チェックを guard の種類ごとの関数(forbidden_line_objection,allowed_line_objection)にまとめ,そこに上の 2 つを加えた(return 数の lint 制限のため).
  • agents/hooks/lib/t3_ownership.py(新規):herdr_ownership.py と同じ構成.PreToolUse で send の宛先が記録済みでなければ ScopeError(ask),PostToolUse で記録する.
  • agents/command_permissions.json:t3 thread start|send|show|list を allow prefix に追加(Codex の規則と Claude の permission はここから生成される.Herdr と同じく,prefix で sandbox の外に出し,細かい判定は hook が行う).
  • agents/claude/settings.json:sandbox.excludedCommands に t3 thread *.
  • agents/hooks/verification_session.py,agents/hooks.json:t3_ownership の呼び出しと,Claude の PostToolUse に Bash(t3 thread start *)(Codex は全 Bash で PostToolUse が走るので追加不要).

thread ID の記録方法と理由

T3 0.1.10 の CLI(binCli-*.mjs)を読んで選んだ.

  • 選んだ方法:start --json の stdout({"threadId", "projectId", "runId"},--wait 付きは {"threadId", "runId", "status", "reply", "error"})を PostToolUse で JSON として読み,最上位の threadId を session の記録に加える.
  • 理由:ID は server が作る.--json なら lane の返答は JSON 文字列の中に escape されて入るので,返答で最上位の threadId を偽れない.--json なしの --wait は stdout が返答そのもので,lane が任意の ID を書けるため記録しない.
  • 退けた方法:--title を t3 thread list --json と照合する方法は,title が一意でなく,人や他の session が同じ title の thread を作れるので退けた.
  • 記録するのは,PATH 上の t3 を直接 1 回だけ呼ぶ,展開も代入もリダイレクトもない t3 thread start ... --json だけ(herdr_ownership.confirm と同じ条件に,./t3 などパス指定の除外を加えた).
  • send の宛先は T3 と同じく前後の空白を除いて照合する.ID は再利用されないので,Herdr のような live 一覧との照合はしない.

テスト

  • Red:tests/hooks/test_t3_thread.py,tests/hooks/test_t3_ownership.py を先に書き,実装前は 43 件失敗(--provider なし・antigravity の start が allow,未知の thread への send が allow,excludedCommands と prefix の欠落など).
  • Green:同じテストが実装後に通過(63 件).
  • 拒否:--provider なし,antigravity(= 形も),利用者名の instance,ClaudeAgent,2 つ目の provider,&& の中,env の後ろ,bash -c の中,パス指定,t3 --log-level info thread start.
  • 確認:--base-dir,T3CODE_HOME=,未知の option,余分な語,option を値に取る形,--,run time の provider,$ARGS,wrapper,send の message なし,未知の action.
  • 所有権:自分が start した thread への send は allow,他・$THREAD・前方一致の ID は ask,&& の 2 つ目と env 経由も確認,別 session には効かない.記録しない応答:--json なし,;・| の後ろ,wrapper,代入,run time の message,./t3,中断,壊れた JSON,空の ID.--wait --json の reply に書いた ID は記録されない.
  • 手動の mutation 23 個(provider 許可リストの拡大,deny 条件,= 形の読み取り,wrapper・代入・spreading の判定,位置引数数,重複 option,--model 必須,.strip(),--base-dir の文法追加,記録条件の各項)をすべて検出(mutmut はこの repo に未導入で,追加は lane の範囲外のため手作業).
  • レビュー指摘への対応:"$(cp /etc/passwd /tmp/leak; echo hi)" の message,"$THREAD",~,展開する heredoc,< /etc/passwd,> /home/user/.bashrc,; で並べた cp,gh … &&,&& curl … が ask になることを追加(修正前は allow で失敗).追加した分岐も手動 mutation 5 個をすべて検出.
  • 再レビューの指摘への対応:/other/repo・project-2 を project にした start,--json なしの start,| jq .・&& の中の start が ask になることを追加(修正前は allow で失敗).追加した条件の手動 mutation 4 個をすべて検出.
  • uv run --frozen pytest(6386 passed,2 skipped),ruff check,ruff format --check,ty check,deptry,vulture,pre-commit.dprint check は変更ファイルで通過(未変更の 43 ファイルが手元の dprint で差分を出すのは main と同じ).

計画との差

  • lane のファイル一覧にない agents/hooks/verification_session.py,agents/hooks.json,tests/hooks/test_herdr_ownership_workspaces.py を変更した.session の記録を持つのは verification_session.py だけで,Claude の PostToolUse は hooks.json に if 条件の登録が要るため.herdr のテストは PostToolUse の if の集合を完全一致で見ているので 1 行足した.他の lane のファイルとは重ならない.
  • pyproject.toml の deptry の first-party 一覧に t3_thread,t3_ownership を追加した(CI の audit が新モジュールを未宣言の依存と判定したため).agents/hooks/lib/literal_words.py も一覧外だが,sandbox 外で動く行を literal に限る既存の仕組みを再利用するために 1 語足した.
  • agents/hooks/rules/*.json は変更していない.provider の必須と許可リストを regex で書くと message の中の --provider に一致してしまうので,判定は t3_thread.py のコードで行う.
範囲・前提・限界
  • 脅威モデルは計画のとおり(agent は t3 thread の引数・message・環境変数を作れる.hook,Nix store,T3 server,GitHub の設定は信頼する).
  • 限界(確認が増えるだけのもの):
    • message を - と heredoc・< file で渡す形,"$(cat brief)" で渡す形は sandbox の外で展開・読み込みが起きるので確認になる(記録もされない).記録させるには t3 thread start ... --json . 'Read <brief> and carry out the lane' のように literal の message を使う.
    • Claude は終了コードが 0 でない Bash に PostToolUse を出さないので,start --wait --json が 1(失敗)や 2(承認・質問待ち)で終わると記録されない.--wait を付けずに start --json し,その後 send --wait で待つ形なら確実に記録される(delegskill lane への申し送り).
    • 別リポジトリへの lane の委譲(project が . 以外)は確認になる.T3 は project を ID → パスの順で解決するので,guard が確かめられるのは . だけ.
    • cd /repo && t3 thread … のように t3 以外のコマンドと並べた行も確認になる.
    • t3 --help や t3 thread start --help のような help も確認になる.
    • 2 つの --provider を両方許可内にした形や,--provider "$P" と --provider antigravity の組は deny(後者)または ask になる.
  • 限界(通るもの):
    • --model の値は検査しない.provider instance が claudeAgent/codex なら,model がどれでも Antigravity にはならない.
  • T3 の CLI がフラグを位置引数の後ろにも置けるか,--x=v を受けるかは実機で試していない.どちらも受けるとみなして判定するので,受けない場合は T3 側がエラーにするだけ.
  • 範囲外:Skill,ADR,cleanup,Herdr の削除.

🤖 Generated with Claude Code

furedea and others added 3 commits November 20, 2026 23:25
t3 thread start, send, show and list leave the Claude sandbox and get
shared allow prefixes, so Codex judges the same forms. The guard refuses
a start without an explicit --provider claudeAgent or codex, since the
project default may be Antigravity, and asks for any form whose words it
cannot read: unknown options, --base-dir, environment assignments,
wrappers, or words split at run time.

Refs #264

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A plain t3 thread start --json records the thread id the T3 server
prints, and a send to any other thread asks, since it may be the user's
or the parent's thread.

Refs #264

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A program named by path, such as ./t3, may be the agent's own script
printing a forged launch result.

Refs #264

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

furedea commented Nov 20, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T06:03:53.386290Z ed9b9d2 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.

@github-actions

Copy link
Copy Markdown

Review summary (read-only): I found no P0–P3 issues worth blocking on.

Read through t3_thread.py, t3_ownership.py, the guard wiring, the verification_session.py hooks and the permission/settings changes.

  • The provider allowlist is an exact match and is checked after the action word. --x=v forms, a repeated --provider, and run-time values all end in deny or ask.
  • Ownership is recorded only from a plain, literal t3 thread start --json whose stdout has a top-level threadId. A reply forged inside a --wait message cannot set that field.
  • Failure modes are conservative. A start that does not match the Bash(t3 thread start *) hook if (for example behind cd … &&) is simply not recorded, so a later send asks.

Limits of this review: I did not run the test suite, and my attempts to run ad-hoc probes of the parser were blocked by the sandbox, so the behaviour above comes from reading the code and tests.

🤖 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: 137fe44894

ℹ️ 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/t3_thread.py Resolved
furedea and others added 2 commits November 21, 2026 02:48
The whole line of an excluded command runs outside the sandbox, so a
substitution in a message, a redirect, or another command in the same
line would run there too. A t3 thread call now passes only in a line
that literal_words accepts: literal t3 calls, joined by &&.

Refs #264

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

furedea commented Nov 20, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary (read-only, no inline findings)

I read t3_thread.py, t3_ownership.py, the guard_command.py, verification_session.py and hooks.json wiring, the permission rules, and the new tests. I did not run the code or the test suite, so these conclusions come from reading only.

  • Provider guard: refusal denies a start unless every --provider value is exactly claudeAgent or codex. A missing, empty, or trailing value is denied. A value known only at run time is skipped by the deny and falls to the ask path. This held up against the bypass forms I could think of: global options, wrappers, --x=v, and a second --provider.
  • Ownership: a send is allowed only when the target id is in the session's recorded set, and a run-time target is an ask. ScopeError maps to ask in failure(), so unreadable forms prompt the user rather than hard-block. Recording the id only from the stdout of one plain, literal t3 thread start --json call mirrors herdr_ownership.
  • Consistency: a threadId is stripped when recorded and when matched. The Claude post-tool-use hook is limited to t3 thread start *. The Codex hook matches all Bash calls.

Observations, none of which I'd block on:

  • If the Codex tool_response is not bare JSON, the start is never recorded. That fails safe, because sends then ask, but it would make the Codex lane prompt on every send. A test with a realistic Codex response shape would confirm it works there.
  • ownership.check returns early on UnsupportedSyntaxError. This is the same behavior as the herdr check, and I assume the permission layer also asks on unparseable input.

No P0 to P3 findings.

@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: d791e99fc1

ℹ️ 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/t3_thread.py Resolved
A redirect on an unsandboxed t3 call reads or writes any file, and
another literal program joined by && would run outside the sandbox with
it. Such lines now ask; a pipe into a read-only filter still runs.

Refs #264

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

furedea commented Nov 21, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary: no P0–P2 findings.

I read t3_thread.py, t3_ownership.py, the guard wiring, the hook registration and the tests. I did not run the suite.

Checks that held up:

  • _provider_values starts scanning right after the start word. Any --provider outside the allow-list is denied, including the = form, a second --provider, and calls behind wrappers or bash -c.
  • A run-time word can't smuggle in an option. Positional counting plus the literal-line requirement in objection turns every such form into ask.
  • confirm records a thread only from the top-level threadId of a direct, literal t3 thread start --json call on PATH. A --wait reply sits inside a JSON string and can't forge that field.
  • A ScopeError from the ownership check reaches the user as ask, not deny.

Minor, not blocking (P3):

  • read() treats any t3 call that contains the word thread anywhere as a thread call. For example, t3 service run thread would get an unreadable-form ask. This only adds prompts and does not weaken the guard.
  • The PR description already notes that the T3 CLI's handling of options after positionals, and of --x=v, is untested against a real binary. A real-binary smoke test would be worth doing before relying on this.

🤖 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: 4ae564ddc9

ℹ️ 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/t3_thread.py Resolved
Comment thread agents/hooks/lib/t3_ownership.py Resolved
A start in another project hands it to an agent with any message, and a
start the session cannot record leaves a thread it may not message. A
start now runs unprompted only as one plain call with --json and the
project named "."; others ask.

Refs #264

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

furedea commented Nov 21, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No P0–P3 findings worth an inline comment.

What I checked (by reading, not by running):

  • t3_thread.refusal: the provider scan starts after the action word. It denies a missing provider, a non-allowlisted provider, or a second --provider outside the allowlist. A run-time --provider value falls through to objection, which asks because the line is no longer literal. I found no way to reach start with an unlisted provider.
  • t3_thread.objection / _parse: unknown options, --, option-like values, spreading words, wrappers, assignments, redirects and non-literal lines all end in ask.
  • t3_ownership.check / confirm: the thread id is recorded only from a single, literal, PATH-resolved t3 thread start --json, and only from the top-level threadId field. Unreadable t3 thread calls escalate to ask, and a send to an unowned or run-time id asks.
  • Wiring: the Claude if: Bash(t3 thread start *) PostToolUse hook, the Codex PostToolUse matcher, the t3 thread * sandbox exclusion, and the command_permissions.json allow rules are consistent with each other.

Limits of this review: I could not execute the code or the test suite in this environment, so the claims above come from reading the code and have not been confirmed by running it. I also did not read the new tests in detail.

Minor, not worth blocking (P3, informational): _thread_words matches the first thread word anywhere after t3. A non-thread subcommand that happens to contain a thread argument is treated as a thread call, so it asks or is denied. This slightly widens the 'other t3 commands unchanged' claim, but it fails closed and is unlikely in practice.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: ed9b9d2b7b

ℹ️ 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
furedea merged commit aa0de7a into main Nov 21, 2026
29 checks passed
@furedea
furedea deleted the feat/guard-t3-thread branch November 21, 2026 07:26
furedea added a commit that referenced this pull request Nov 21, 2026
…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]>
furedea pushed a commit that referenced this pull request Nov 21, 2026
🤖 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>
furedea added a commit that referenced this pull request Nov 28, 2026
…policy (#286)

## 概要

agent-harness が描画と配置だけを担うようになり(furedea/agent-harness#262),これまで harness
が合成していた保護とエージェント用 GitHub トークンの配線が消えた.その代わりをこのリポジトリのソース設定とフックで持つ.

- 保護は「書き込みの許可リスト+ハーネスのルートごとの拒否」にした.ルートは
`agents/hooks/rules/harness_roots.json` に 1 か所で宣言し,Claude と Antigravity
のネイティブの拒否,および全 provider 共通の `guard_file.py harness`
がそれに従う.テストが各設定と宣言の一致を確かめる.
- フックは生成ファイル `protected_paths.json` を読まなくなった.`harness_roots.json`
を読み,対象が(`.` と `..` を畳んだうえで)いずれかのルートの中なら拒否する.
- GitHub:`gh` を Claude の sandbox の中で動かし,`github.com` と `api.github.com`
への通信を許す.Codex は guarded プロファイルで動く.`GH_CONFIG_DIR` の値はホストごとの絶対パスで,Claude
の `env` も Codex の `shell_environment_policy.set` も `~`
を展開しないため,ソースには書かずホスト(dotfiles,サーバーでは `bootstrap_server.sh`)が渡す(ユーザーの決定).
- App の鍵は,`~/.ssh` 全体の読み取り拒否として各 provider
のネイティブ設定に明示した.ソースには鍵のファイル名を書かない.
- ADR-0031 を追加し,ADR-0013 を partly-superseded にした.

Closes #285

## 移行項目の対応表

### furedea/agent-harness#265(保護)

- [x] フックの `protected_paths.json` 依存を外す →
`agents/hooks/guard_file.py`,`agents/hooks/rules/harness_roots.json`(Codex,Devin,Hermes,Pi,dsh,Antigravity
のアダプターも同じフックを通る)
- [x] Claude `permissions.deny` にルートごとの `Edit(...)` →
`agents/claude/settings.json`(`~/.claude/**`,`~/.codex/**`,`~/.devin/**`,`~/.config/devin/config.json`,`~/.hermes/**`,`~/.pi/**`,`~/.dsh/**`,`~/.gemini/config/**`,`~/.gemini/antigravity-cli/settings.json`)
- [x] Claude `sandbox.filesystem.denyWrite` → 追加不要.`allowWrite`
はどのルートも含まない(テストで固定)
- [x] Codex:ルートを書けない guarded プロファイル →
`agents/codex/config.toml`(`":root" = "read"`,書き込みは作業ディレクトリ,一時領域,Claude
の `allowWrite` と同じキャッシュだけ.テストで Claude と一致を固定)
- [x] Antigravity `agentMode = ""`,`enableTerminalSandbox = true` →
`agents/antigravity/settings.json`(新規)
- [x] Antigravity `read_file(/nix)`,`read_file(/run)` の許可,`/run`
の秘密のマウント 8 つの `read_file(...)` の拒否 → 同上
- [x] Antigravity の各ルートの `write_file(...)` 拒否 → 同上
- [x] Devin,Hermes,Pi,dsh → ネイティブの規則の面がないので,フック(`harness_roots.json`)で拒否
- [x] dotfiles の `--dsh-profile` → このリポジトリは使っていない(対応なし)

### furedea/agent-harness#264(GitHub トークン)

- [x] Claude `sandbox.enableWeakerNetworkIsolation = true` → 既にソースにある
- [x] Claude `sandbox.network.allowedDomains` に
`github.com`,`api.github.com` → `agents/claude/settings.json`
- [x] Claude `sandbox.excludedCommands` から `gh *` を外す → 同上
- [x] Claude の鍵の拒否(`permissions.deny` と `sandbox.filesystem.denyRead`
の両方)→ `Read(~/.ssh/**)` と `~/.ssh`(鍵のパスを含む `~/.ssh`
全体.`secret_path_policy.json` の `~/.ssh/**`,`**/*.pem` でも生成される)
- [x] `<configDir>` を隠す規則を置かない → テスト
`test_agents_can_read_the_agent_gh_config_the_host_mints`
- [x] Codex `default_permissions =
"guarded"`,`":root"`,`":tmpdir"`,`":slash_tmp"`,`":workspace_roots"."."`,キャッシュの
`"write"`,`[permissions.guarded.network] enabled = true` →
`agents/codex/config.toml`
- [x] Codex の鍵の拒否 → `"~/.ssh" = "deny"`(加えて harness が `"~/.ssh/**" =
"none"` を生成)
- [x] Codex `"~/.config/gh/hosts.yml" = "deny"` →
`secret_path_policy.json` から harness が `"none"` を生成(従来どおり)
- [x] Antigravity `read_file(~/.config/gh/hosts.yml)` →
`secret_path_policy.json` から生成(従来どおり)
- [x] Antigravity の鍵の拒否 → `read_file(~/.ssh)`(ソースに明示,生成とも重複は畳まれる)
- [ ] Claude `env.GH_CONFIG_DIR`,Codex
`shell_environment_policy.set.GH_CONFIG_DIR` → **dotfiles
が渡す**(下記).ソースには書かない
- [ ] トークンの発行と更新 → dotfiles(furedea/dotfiles のトークン lane).サーバーは下記のフォローアップ

### furedea/agent-harness#263(Pi の srt 拡張)

- [x] `manifest.json` の `runtime_commands` に `srt` はない,Pi のためだけの sandbox
エントリもない → 対応なし

## 旧版との意図した違い

- ルート単位の拒否になったため,ファイルツールは `~/.claude/plans`(plan mode の計画ファイル)や
`~/.claude/keybindings.json`
など,ルート配下のすべてを書けない.旧版はインストールしたファイルだけを拒否していた.現在 `~/.claude/plans` は空で,plan
mode は使われていない.
- スキル(`~/.claude/skills` など)も保護される.旧版は保護していなかった.
- Codex は main checkout で `.git/worktrees` 全体を書けない(Codex がグロブのエントリに
`deny` しか受け付けず,`config.worktree` は git が読むため).Claude は `config.worktree`
だけを拒否する.Codex の lane は worktree で動き,共通の `.git` は元々作業領域の外なので影響しない.
- Codex の guarded プロファイルで,フックだけが書く状態と作業領域の `.git/hooks`,`.git/config`
を書けなくなった(旧版は書けた).
- 鍵の拒否は鍵のファイル単体ではなく `~/.ssh` 全体(従来から秘密パスのポリシーで拒否していた範囲と同じ).
- App の鍵がないホストでも,GitHub への通信が sandbox で開き,`gh` は sandbox の中で未認証で動く.旧版は
`gh` を sandbox の外でユーザー自身のログインで動かしていた.

## dotfiles が用意するもの

- `GH_CONFIG_DIR = <home>/.config/agent-harness/gh`(旧既定値と同じ絶対パス)を,Home
Manager の `programs.agent-harness.claude.settings.env` と
`programs.agent-harness.codex.settings.shell_environment_policy.set`
に足す(`NVIM_LOG_FILE` と同じ形).
- トークンを `<home>/.config/agent-harness/gh/hosts.yml`(0600,一時ファイルからの
rename)に書くスクリプトと,その定期実行.
- 鍵は `~/.ssh/` の下に置いたままにする(ここに置く限り,上の拒否が効く).

## マージ後にユーザーが確かめること

- dotfiles を新しい agent-harness に上げて切り替えたあと,Codex
のセッションで作業領域への書き込みができ,`.git/hooks` と `~/.claude` への書き込みが拒否されること.このレーンの
sandbox の中では `codex sandbox` が入れ子の seatbelt を作れず,設定の読み込みまでしか確かめられなかった.
- Claude のセッションで `gh auth status` がエージェントの身元を示すこと(トークンは表示しない).

## 必要な agent-harness のリビジョン

- この PR のソースは,ロック中の 0.9.15(c5b1303)と,#263〜#265 を含む main の 2008c43 の両方で
`install` と `verify` が成功し,描画結果に保護,GitHub の配線,鍵の拒否が入ることを確かめた.
- dotfiles は 2008c43 以降へ上げてよい(この PR のマージ後).

## フォローアップ

- agent-config:`scripts/bootstrap_server.sh` は `agent-harness
github-app-token refresh` でトークンを発行している.固定中のリリースでは動くが,#264
を含むリリースへ上げるとこのサブコマンドがなくなるので,その前に dotfiles と同じ形の発行スクリプトへ置き換える.
- agent-config:`docs/DESIGN.md` の「`denyWrite`
はまだ効いていない(agent-harness#213)」は,両方のリビジョンの描画で `denyWrite`
がソースのまま出ていたので,記述の見直しが要る.

## レビュー対応

- 相対パスとシンボリックリンクでルートの判定をすり抜ける(claude-review P2):payload の `cwd`
から解決し,字句上のパスと解決後のパスの両方で判定するよう修正した(dabd8070).
- GitHub への通信路(claude-review P3):旧版と同じ構成なのでコードは変えず,ADR-0031
に追記した(caf37603).
- Codex の guarded プロファイルが Claude の
`denyWrite`(フックだけが書く状態,`.git/hooks`,`.git/config`,`config.worktree`)を写していない(claude-review
P1):`"read"` で写し,テストで Claude
と一致を固定した(45257d64).旧版が合成していたプロファイルにも同じ欠落があった.
- codex-review は「レビューを完了できなかった」で失敗した(使用量制限など).

## 検証

- Red:`tests/hooks/test_guard_file.py` の新しい契約(28 件)と
`tests/test_harness_protection.py`(宣言ファイルがない,鍵の拒否がない)が実装前に失敗することを確認した
- `uv run pytest`:6662 passed,2 skipped
- `bats tests/bootstrap_server.bats`:81 件成功
- `ruff check`,`ruff format --check`,変更ファイルの `dprint check`,`nix run
.#adr-check -- docs/adr`:成功
- 新旧 2 つの agent-harness で一時ディレクトリへ `install` と `verify`,配置した
`guard_file.py harness` がルート配下を拒否し,作業ディレクトリのファイルを許すことを確認した

🤖 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