Repository navigation
feat(settings)!: declare the harness protection and the agent GitHub policy - #286
Conversation
agent-harness no longer writes the protected_paths.json list the harness guard read, so the guard would refuse every edit after an upgrade. The guard now reads agents/hooks/rules/harness_roots.json, one entry per harness root, and refuses any file-tool target inside a root after collapsing `.` and `..`. Refs #285 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…policy agent-harness only renders and installs now, so each provider's settings here carry what it used to compose: file tools are denied every harness root (Claude Edit, Antigravity write_file), Codex commands run in a guarded profile that writes only what Claude's sandbox writes, Antigravity keeps its default mode and terminal sandbox and the /run secret mounts stay unreadable, ~/.ssh is unreadable in every native surface, and gh runs inside the Claude sandbox, which reaches github.com and api.github.com. ADR-0031 records the decision and partly supersedes ADR-0013. BREAKING CHANGE: the host must set GH_CONFIG_DIR to the agent token directory in the Claude env and the Codex shell environment, since the source holds no host path; gh no longer runs outside the Claude sandbox. Refs #285 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
Codex Review Summary: ❌ FailedThis 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. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Review summaryRead-only review of the harness-roots protection and the agent GitHub policy. I found no blocking problems. I did not run the test suite.
Checked and fine: component-wise root matching ( 🤖 Generated with Claude Code |
…h links A relative target was compared as written, so `../.claude/x` from a project directory or a symlink into a root slipped past the guard, which is the only write guard for Devin, Hermes, Pi and dsh. The guard now reads the target from the payload cwd and refuses it when either its collapsed path or its resolved path lies inside a root. Refs #285 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs #285 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Review summaryI found one problem that should block the merge.
The rest looks correct:
I didn't run the test suite myself. The pass counts above come from the PR description. 🤖 Generated with Claude Code |
… profile Every Codex command now runs in the guarded profile, which let commands write the hook-owned state and a workspace's .git hooks and config that Claude's sandbox keeps in denyWrite. The profile now marks them read-only. Codex accepts only deny on a glob entry and Git must read config.worktree, so all of .git/worktrees is read-only instead. Refs #285 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Review summary (read-only): no blocking findings. I read the config and hook changes in full and spot-checked the test diffs. I did not run the test suite.
Two things I could not check from the diff, so they are notes rather than findings:
|
🤖 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>
agent-harness 2008c43 drops the github option and composedSettings; agent-config ac335be (furedea/agent-config#286) denies reading ~/.ssh for every provider. The checks now compose the provider settings the way the agent-harness module does, and the old option counts as removed when reading it fails. Refs #531 Co-Authored-By: Claude Opus 5.5 <[email protected]>
## 概要 furedea/agent-harness#264 でエージェント用 GitHub トークンの発行機能が agent-harness から削除されたため,発行を dotfiles に移した. - `scripts/github-app-token/mint_github_app_token.sh`(新規): `openssl`,`curl`,`jq` でトークンを発行する.`jq` は既存の依存. - App の鍵で RS256 の JWT に署名する. - `GET /app/installations` で App のインストールが 1 つだけであることを確かめ,`POST /app/installations/{id}/access_tokens` でトークンを発行する. - `<設定ディレクトリ>/hosts.yml` を一時ファイルからの rename で mode 0600 で書く.設定ディレクトリは 0700.`config.yml` がなければ `version: "1"` を書く. - 失敗したときは今の `hosts.yml` をそのまま残す. - JWT とトークンは標準入力で curl に渡すので,argv にも出力にも出ない. - **2 回前のトークンの失効**: 置き換える `hosts.yml` を同じディレクトリの `hosts.previous.yml`(mode 0600,一時ファイルからの rename)に残す.新しい `hosts.yml` に置き換えた後,`hosts.previous.yml` にあったトークン(2 回前の実行で発行したもの)を,そのトークン自身で `DELETE /installation/token` して失効させる. - 有効なトークンは最大 2 つになる.実行の直前に始まった `gh run watch` のような長い `gh` も,その次の実行まで(少なくとも 15 分)動き続ける. - 漏れたトークンは最大 30 分で失効する(もともと 1 時間で期限切れ). - 1 回目と 2 回目の実行は何も失効させない. - 発行に失敗したときは `hosts.yml` も `hosts.previous.yml` も変えず,何も失効させない. - 401 は期限切れなので何も出さない. - ほかの失敗はトークンを含めずにログへ出し,実行は成功として終える. - **権限の絞り込み**: 権限の指定を必須にし,指定がなければ usage で失敗する.App の全権限を持つトークンは発行されない. - `nix/home/default.nix`: - `programs.agent-harness.github.agentToken` を削除した. - launchd エージェント `agent-github-token` を両ホストに追加した(`RunAtLoad`,15 分ごとに実行,ログは `~/Library/Logs/agent-github-token.log`). - App ID,鍵のパス,設定ディレクトリ `~/.config/agent-harness/gh` は旧版と同じ. - Claude の `env` と Codex の `shell_environment_policy.set` に `GH_CONFIG_DIR` を設定した.source の設定は `~` を展開しないので,dotfiles が絶対パスで渡す. - `flake.lock`: agent-harness を 249aeac(0.10.0,furedea/agent-harness#268 を含む)に,agent-config を 4ea2075(0.6.0,furedea/agent-config#286 を含む)に一緒に更新した. - furedea/agent-harness#268 は,ソースの `mcp_servers.json` と Home Manager の `mcpServers` に宣言した MCP サーバーを,各プロバイダーの設定に生成する. - dotfiles と agent-config は MCP サーバーを宣言していないので,生成されるのはサーバーを含まない空のファイルだけ.`darwin-rebuild` 後に Mac に現れるのは次の 2 つ. - `~/.gemini/config/mcp_config.json`: 新しい activation `agentHarnessAntigravityMcpServers` が,なければ作る. - `~/.gemini/config/.agent-harness-managed.json`: そのサイドカー(`{"mcpServers": []}`). - 既存の `~/.codex/.agent-harness-managed.json` に空の `mcp_servers` が加わる.Codex の `config.toml` に `[mcp_servers]` は増えず,Claude の skills ツリーのファイル構成も変わらない.Devin は有効にしていないので `~/.config/devin` には何も書かれない. - agent-config 側の差分は 0.6.0 のリリースと依存の更新(hypothesis,ruff). - `nix/checks.nix`: - 新しい agent-harness は `composedSettings` を公開しないので,モジュールと同じ評価(source の設定に Home Manager の `settings` を `recursiveUpdate` で重ねる)で生成後の設定を組み立てるようにした. - 契約を追加した. - 旧 `github` オプションが削除済みであること - 両ホストのジョブの引数(App ID,鍵,設定ディレクトリ,権限) - 実行間隔が 1 時間の有効期限の 1/3 未満であること - Claude と Codex の `GH_CONFIG_DIR` - 組み込んだスクリプトが実行できること(darwinOnly) - Claude,Codex,Antigravity のそれぞれで鍵が読み取り拒否されていることを確かめる契約を追加した. - **Claude**: `Read(...)` と `denyRead` の両方 - **Codex**: `default_permissions` のプロファイルの filesystem に `"deny"` - **Antigravity**: `read_file(...)` - 鍵そのものに加え,`~/.ssh` などの親ディレクトリの拒否も鍵を含むものとして扱う. - 設定を生成するプロバイダーが増えたら失敗する契約もある. - ADR-0055 を追加し,README を更新した. Closes #531 ## 権限の選び方 `GET /apps/furedea-agent` で調べた App の権限は `actions:read`,`contents:write`,`issues:write`,`metadata:read`,`pull_requests:write` だった.エージェントはどれも使うので,5 つすべてを明示して要求する. | 権限 | 使い道 | | --- | --- | | `actions:read` | CI の確認 | | `contents:write` | push | | `issues:write` | Issue | | `pull_requests:write` | PR | | `metadata:read` | 常に必要 | 絞り込みの効果は,後から App に権限を足しても,dotfiles に書き足すまでエージェントには渡らないこと.リポジトリは絞らなかった.インストールが所有者の全リポジトリを対象にしていて,エージェントは複数のリポジトリにまたがって作業するため. ## マージ後の手順(各 Mac で) トークンは表示しない. 1. `sudo darwin-rebuild switch --flake ~/ghq/github.com/furedea/dotfiles#<host>` で反映する. 2. launchd エージェントが動いたことを確かめる. - `launchctl print gui/$(id -u)/org.nix-community.home.agent-github-token | grep -E 'state|last exit code'` で `last exit code = 0` になっている. - `~/Library/Logs/agent-github-token.log` にエラーがない. 3. エージェントの身元で gh が動くことを確かめる. - `GH_CONFIG_DIR=~/.config/agent-harness/gh gh api /installation/repositories --jq .total_count` が数を返す. - `stat -f %Lp ~/.config/agent-harness/gh/hosts.yml` が `600` を返す. 4. 新しく起動した Claude Code または Codex のセッションで `gh pr list --repo furedea/dotfiles` が動く. 5. 旧版の状態ファイル `~/.config/agent-harness/gh/agent_harness_token.json` は不要なので消してよい. ## 検証 - `bats tests/github-app-token`: 22 件すべて成功.スクリプトを作る前,失効と権限を足す前,2 回前の失効に変える前の各段階で,テストが先に失敗することを確認した. - `nix flake check`: 成功(`all checks passed!`). - lock 更新前は次の 4 件が失敗し,更新後に通ることを確認した. - `agent-harness-github-option-removed`(旧 `agent-harness-has-no-github-option`) - `github-app-key-unreadable-by-claude`,`-codex`,`-antigravity` - `GH_CONFIG_DIR` の 2 件は,dotfiles で設定した時点で通った. - `bats --recursive tests`(137 件): 今回の変更による失敗はなし.ローカルのサンドボックスで zsh の ssh-agent の 8 件と nvim の lspmux の 1 件が失敗したが,原因は Unix ソケットの listen と `~/.local/state/nvim` への書き込みの拒否で,今回の変更とは関係ない. - shellcheck,shfmt,lefthook,commitlint: 成功. - Nix のチェック `agent-github-token-script`(darwinOnly): bats の仕様を,launchd ジョブと同じ固定ツール(`nix/agent_github_token.nix`,curl のみ偽物)で実行し,22 件すべて成功. - CI: `codex-review` と,それに連動する `all-green` 以外はすべて成功.`codex-review` は利用上限で実行されていない(Codex のコメントで確認). - 実際の鍵とトークンは,読み取りも表示もしていない.テストは使い捨ての鍵と偽の curl を使う. ## レビュー対応 - **P1(Claude)**: launchd ジョブの `TOOLS_PATH` に `sed` がなく,2 回目以降の実行が exit 127 で失敗してトークンが更新されなくなる. - 29e11c7 で修正した.前のトークンは bash の正規表現で読むようにした. - bats の仕様をジョブと同じ固定ツールで実行する Nix チェックを足した.修正前のスクリプトで,このチェックが `sed: command not found` で失敗することを確認した. - **P2(Claude)**: 前のトークンをすぐ失効させるため,次の実行より長く動く `gh`(`gh run watch` など)が 401 になる. - 所有者の判断で,2 回前のトークンを失効させる方式に変えた(ae6e9e1).有効なトークンは最大 2 つ,漏れたトークンは最大 30 分で失効する. - ADR-0055 の Decision と Consequences を更新した(b4fecc3). - **P3(Claude)**: Claude Code の `Read(/path)` はプロジェクトからの相対パスとして読まれるので,鍵の契約が保護にならないエントリーを通しうる. - 398e377 で修正した.`Read(` の絶対パスは `//` で始まるものだけを数える. - **P3(Claude,変更なし)**: revoke の対象が `hosts.yml` の値をそのまま使う点.指摘自身が問題なしとしている.エージェントがそのディレクトリに書けても,送られるのはエージェントがすでに持つトークンだけ. - **P3(Claude,変更なし)**: checks は agent-harness の合成を再現していて,生成結果そのものは読んでいない.生成結果を読むには評価時のビルド(IFD)が要るので,今の形にとどめた.agent-harness の合成方法が変わったときは見直す. - 最終の再レビュー(Claude): P0〜P2 の指摘なし.未解決のスレッドなし. - 2 回前の失効と lock 更新後の再レビュー(Claude): P0〜P2 の指摘なし.P3 として,PR 本文の失効方式と lock のリビジョンが古いと指摘された.push 直後に本文を更新しており,どちらも反映済み. - Codex: 利用上限のため 2 回とも実行されていない. - CI の bats で,GNU の `stat -f` によって mode の確認がずれていた.テストの補助関数で `stat -c` を先に試すように直した. ## 計画からの逸脱 - JSON の読み取りに既存の `jq` を使った.インストール一覧の応答には入れ子の `id` があり,sed では確実に読めないため. - 期限を追跡せず,毎回発行する.状態は前の `hosts.yml` だけで済む代わりに,1 台あたり毎時 4 回の発行と失効になる(ADR-0055). - `nix/checks.nix` で agent-harness の合成を再現した.新しい agent-harness が `composedSettings` を公開しなくなったため. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
概要
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を読み,対象が(.と..を畳んだうえで)いずれかのルートの中なら拒否する.ghを Claude の sandbox の中で動かし,github.comとapi.github.comへの通信を許す.Codex は guarded プロファイルで動く.GH_CONFIG_DIRの値はホストごとの絶対パスで,Claude のenvも Codex のshell_environment_policy.setも~を展開しないため,ソースには書かずホスト(dotfiles,サーバーではbootstrap_server.sh)が渡す(ユーザーの決定).~/.ssh全体の読み取り拒否として各 provider のネイティブ設定に明示した.ソースには鍵のファイル名を書かない.Closes #285
移行項目の対応表
furedea/agent-harness#265(保護)
protected_paths.json依存を外す →agents/hooks/guard_file.py,agents/hooks/rules/harness_roots.json(Codex,Devin,Hermes,Pi,dsh,Antigravity のアダプターも同じフックを通る)permissions.denyにルートごとのEdit(...)→agents/claude/settings.json(~/.claude/**,~/.codex/**,~/.devin/**,~/.config/devin/config.json,~/.hermes/**,~/.pi/**,~/.dsh/**,~/.gemini/config/**,~/.gemini/antigravity-cli/settings.json)sandbox.filesystem.denyWrite→ 追加不要.allowWriteはどのルートも含まない(テストで固定)agents/codex/config.toml(":root" = "read",書き込みは作業ディレクトリ,一時領域,Claude のallowWriteと同じキャッシュだけ.テストで Claude と一致を固定)agentMode = "",enableTerminalSandbox = true→agents/antigravity/settings.json(新規)read_file(/nix),read_file(/run)の許可,/runの秘密のマウント 8 つのread_file(...)の拒否 → 同上write_file(...)拒否 → 同上harness_roots.json)で拒否--dsh-profile→ このリポジトリは使っていない(対応なし)furedea/agent-harness#264(GitHub トークン)
sandbox.enableWeakerNetworkIsolation = true→ 既にソースにあるsandbox.network.allowedDomainsにgithub.com,api.github.com→agents/claude/settings.jsonsandbox.excludedCommandsからgh *を外す → 同上permissions.denyとsandbox.filesystem.denyReadの両方)→Read(~/.ssh/**)と~/.ssh(鍵のパスを含む~/.ssh全体.secret_path_policy.jsonの~/.ssh/**,**/*.pemでも生成される)<configDir>を隠す規則を置かない → テストtest_agents_can_read_the_agent_gh_config_the_host_mintsdefault_permissions = "guarded",":root",":tmpdir",":slash_tmp",":workspace_roots".".",キャッシュの"write",[permissions.guarded.network] enabled = true→agents/codex/config.toml"~/.ssh" = "deny"(加えて harness が"~/.ssh/**" = "none"を生成)"~/.config/gh/hosts.yml" = "deny"→secret_path_policy.jsonから harness が"none"を生成(従来どおり)read_file(~/.config/gh/hosts.yml)→secret_path_policy.jsonから生成(従来どおり)read_file(~/.ssh)(ソースに明示,生成とも重複は畳まれる)env.GH_CONFIG_DIR,Codexshell_environment_policy.set.GH_CONFIG_DIR→ dotfiles が渡す(下記).ソースには書かないfuredea/agent-harness#263(Pi の srt 拡張)
manifest.jsonのruntime_commandsにsrtはない,Pi のためだけの sandbox エントリもない → 対応なし旧版との意図した違い
~/.claude/plans(plan mode の計画ファイル)や~/.claude/keybindings.jsonなど,ルート配下のすべてを書けない.旧版はインストールしたファイルだけを拒否していた.現在~/.claude/plansは空で,plan mode は使われていない.~/.claude/skillsなど)も保護される.旧版は保護していなかった..git/worktrees全体を書けない(Codex がグロブのエントリにdenyしか受け付けず,config.worktreeは git が読むため).Claude はconfig.worktreeだけを拒否する.Codex の lane は worktree で動き,共通の.gitは元々作業領域の外なので影響しない..git/hooks,.git/configを書けなくなった(旧版は書けた).~/.ssh全体(従来から秘密パスのポリシーで拒否していた範囲と同じ).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/の下に置いたままにする(ここに置く限り,上の拒否が効く).マージ後にユーザーが確かめること
.git/hooksと~/.claudeへの書き込みが拒否されること.このレーンの sandbox の中ではcodex sandboxが入れ子の seatbelt を作れず,設定の読み込みまでしか確かめられなかった.gh auth statusがエージェントの身元を示すこと(トークンは表示しない).必要な agent-harness のリビジョン
installとverifyが成功し,描画結果に保護,GitHub の配線,鍵の拒否が入ることを確かめた.フォローアップ
scripts/bootstrap_server.shはagent-harness github-app-token refreshでトークンを発行している.固定中のリリースでは動くが,feat(delegation): hand approved lanes to T3 Code threads with a tool-neutral delegation skill #264 を含むリリースへ上げるとこのサブコマンドがなくなるので,その前に dotfiles と同じ形の発行スクリプトへ置き換える.docs/DESIGN.mdの「denyWriteはまだ効いていない(agent-harness#213)」は,両方のリビジョンの描画でdenyWriteがソースのまま出ていたので,記述の見直しが要る.レビュー対応
cwdから解決し,字句上のパスと解決後のパスの両方で判定するよう修正した(dabd8070).denyWrite(フックだけが書く状態,.git/hooks,.git/config,config.worktree)を写していない(claude-review P1):"read"で写し,テストで Claude と一致を固定した(45257d64).旧版が合成していたプロファイルにも同じ欠落があった.検証
tests/hooks/test_guard_file.pyの新しい契約(28 件)とtests/test_harness_protection.py(宣言ファイルがない,鍵の拒否がない)が実装前に失敗することを確認したuv run pytest:6662 passed,2 skippedbats tests/bootstrap_server.bats:81 件成功ruff check,ruff format --check,変更ファイルのdprint check,nix run .#adr-check -- docs/adr:成功installとverify,配置したguard_file.py harnessがルート配下を拒否し,作業ディレクトリのファイルを許すことを確認した🤖 Generated with Claude Code