Repository navigation
feat(hooks): judge gh calls by effect through a policy table - #201
Conversation
|
@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. |
レビュー要約ブロッキング指摘は 2 件(P1)です.詳細はインラインコメントにあります.
書き込み側(オプション表による検査,対象 repo の解決,irreversible フラグ,GraphQL の mutation 判定)は読んだ範囲で問題は見つかりませんでした. レビューは静的読解のみです.hook を実際に動かして再現確認はしていません(環境の権限制約のため). 🤖 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: ff80b286b8
ℹ️ 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".
|
@codex review |
Review summaryThe effect-based design looks sound. GraphQL parsing, REST route matching, dot-segment rejection and the C/D adjacent forms are handled carefully, and the tests cover them well. I found 1 blocking issue and 2 minor ones.
Blocking findings (P0/P1): 1 🤖 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: 4aff96c7fd
ℹ️ 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".
|
@codex review |
Review summaryI found no P0 or P1 problems. Moving gh from regex rules to a policy table makes the guard stricter overall: dynamic option words, Three P2 findings, posted inline:
I couldn't run probe tests in this sandbox, so these findings come from reading the code and pflag's parsing rules. None of these cases has a test yet. blocking_findings: 0 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 36c4e0b428
ℹ️ 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".
|
@codex review |
Review summary1 P1 and 2 P2 findings. All three are cases where the new effect-based gh guard now allows a call that sends a secret off the machine. Before this PR, each of these forms asked for confirmation because it contains a variable.
The review is static only. This sandbox would not let me run the guard on these commands. I traced each one through the code. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1b5167bd4
ℹ️ 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".
|
@codex review |
レビュー結果ブロッキング 1 件(P1),軽微 1 件(P2).
テストについて:値をつなげて書く形( 🤖 Generated with Claude Code |
Review summary (read-only)No findings. Nothing blocks the merge. I couldn't run the tests in this environment (the commands needed approval), so this is a static read only. I read:
What I checked, and why each part holds up:
Two observations, neither a defect:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a7c820d18d
ℹ️ 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".
The hook runs outside the sandbox and may hold another environment than the sandboxed shell, so expanding a body path with it can scan a different file than the one gh sends. A body file named at run time now asks, as before the expansion was added; literal body files are still scanned. The GitHub Gateway under #181 removes the mismatch by judging requests outside the sandbox. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
Review summary (read-only)I found nothing at P0–P3 that I'm confident enough to report. What I checked:
The behaviour changes that stand out ( Not run: I couldn't execute the test suite in this environment. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8083df1f86
ℹ️ 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".
|
@codex review |
Review summary (read-only)No inline findings: I found no P0–P2 problems in the gh policy rewrite. What I read (static review of the new code):
Checked and found consistent with the PR description:
Not verified:
P3 notes (optional, no action needed to merge):
🤖 Generated with Claude Code |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
🤖 I have created a release *beep* *boop* --- ## [0.2.0](v0.1.4...v0.2.0) (2026-11-18) ### Features * add adr-check command for MADR ADRs ([#225](#225)) ([138c542](138c542)) * **adr:** adopt the shared ADR checks ([#226](#226)) ([5c94a78](5c94a78)) * **hooks:** block edits on static rule errors and guard ast-grep-ignore ([#203](#203)) ([f5b3317](f5b3317)) * **hooks:** judge gh calls by effect through a policy table ([#201](#201)) ([db7226d](db7226d)) * **hooks:** keep ask prefixes only for widening authority and promotion ([#199](#199)) ([c3985f6](c3985f6)) * **hooks:** migrate TypeScript style rules to ast-grep and jev-lint checks ([#195](#195)) ([24d1a3e](24d1a3e)) * **lint:** flag Go packages under util and common with an error rule ([#202](#202)) ([de25e1d](de25e1d)) * **lint:** judge ADR rationale with Jev ([#228](#228)) ([cf1c0a3](cf1c0a3)) * **lint:** migrate agents/AGENTS.md rules to model rules and linters ([#191](#191)) ([9e3e37d](9e3e37d)) * **lint:** migrate bash-style and github-actions-style rules to checks ([#194](#194)) ([4e473ba](4e473ba)) * **lint:** migrate go-style rules to ast-grep and jev-lint rules ([#190](#190)) ([296ad84](296ad84)) * **lint:** migrate rust-style prose rules to checks ([#193](#193)) ([e184682](e184682)) ### Bug Fixes * **ci:** run the jev-lint model-rule tests in CI ([#218](#218)) ([1919b06](1919b06)) * **deps:** pin dependencies ([#221](#221)) ([5d083e4](5d083e4)) * **hooks:** deny git options that skip repository hooks ([#212](#212)) ([e10e5b6](e10e5b6)) * **hooks:** judge a cell turned into code from scratch and ignore attribute reasons ([#224](#224)) ([96fb561](96fb561)) * **lint:** close blocking ast-grep rule gaps recorded in [#196](#196) ([#216](#216)) ([fa31947](fa31947)) * **skills:** drop the agent-run verify step that protected records block ([#213](#213)) ([700244d](700244d)) --- 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>
## 概要 Python の jev-lint 規則 19 件すべてに fixtures と `expect.yml` を用意し,`jev-lint eval`(3 passes)で精度を測った.仮の 0.5 だった cutoff を fitted midpoint に置き換え,根拠を各 `rule.yml` のコメントに書いた.親セッションの指示に従い,この回はどの規則も昇格させず(全規則 advisory のまま),python-style skill の文章も消していない. ## 変更 - 17 規則に `fixtures/` と `expect.yml` を追加した(`command-query-naming` と `error-message-names-operation` は既存).どの規則も 6〜10 件で,判定の分かれやすい clean を入れている.located の規則はファイル全体がモデルに渡るため,ラベルが漏れないよう fixture のコードには Bad/Clean のコメントを書かず,理由は `expect.yml` の `why` に書いた. - 19 規則の `baseline.json` を追加・更新した(ユーザー実行の `eval --accept`). - cutoff を fitted midpoint に置き換え,根拠のコメントを書いた.fixtures の両側の余白が広い 8 規則には `inconclusive:`(blind の理由)を書いた. - #196 の指摘への対応: - [x] `json-parse-uses-model-validate-json`:callee(`function` が `model_validate` で終わる attribute)で照合する.`Response(Order.model_validate(data))` の外側の呼び出しは subject にならない. - [x] `fixture-justified`:「軽量なら」「helper で足りるなら」「scope が広すぎるなら」を「2 件未満」の分岐の中にまとめた.2 件以上ならどんな場合も違反ではない. - [x] `frozen-model-subclass-keeps-locked-settings`:文脈の広さは `located` のままとした.`graph` arm はソースを渡さず,同じファイルの記号しか載らないため,別ファイルの基底をたどる問題は解決しない.同じファイル内の継承の連鎖と,`FrozenBaseModel` を直接 import する子クラスは判定できる.別ファイルの中間クラスを経由する子孫は判定できないので,Limits に記録した. - 分離しなかった規則の書き直し(理由は「規則ごとの結果」の表を参照): - `import-name-self-explanatory`:`state` を `local` から `located` にした(名前の衝突や呼び出し箇所は import の外にあるため).criteria に「パスが 1〜2 部分」「3 部分以上は長い」「慣例でない 1〜2 文字の alias」という基準を書いた. - `no-exposed-mutable-collection`:`state` を `located` にした(返す field が tuple か,クラスが不変条件を守るかは `__init__` とクラス定義にあり,`local` では見えない). - `frozen-model-subclass-keeps-locked-settings`:基底の値を明記し,同じ値を繰り返すだけ(`strict=True`)なら違反ではないと書いた. - `import-name-self-explanatory` の `expect.yml` を `window: 0` にした.1 行ずつ並ぶ import では `window: 1` のラベルが隣の行にも及び,bad が優先されて clean が bad として数えられていた. - `.ignore`(新規)と `pyproject.toml` の `[tool.deptry] extend_exclude`:fixtures に植えた違反(`BaseModel` の直接継承,`slots` なしの dataclass,架空のパッケージの import)を,CI の ast-grep と deptry が報告しないようにする.ruff,ty,vulture には同じ除外がすでにある. - `tests/hooks/test_model_rules_tiers.py`:baseline を持つ規則が先に cap を使う tier になるので,`function-single-purpose` を「未調整」と仮定していたテストを,全言語に baseline が揃って 1 tier になっても壊れない形に変えた. ## 規則ごとの結果 `jev-lint eval --replay`(baseline は 2026-11-18,3 passes,平均値).「最高 clean」「最低 bad」は fixture の平均値. | 規則 | bad / clean | 0.5 での tp / fp / fn | 最高 clean | 最低 bad | 新 cutoff | 判定 | | --- | --- | --- | --- | --- | --- | --- | | command-query-naming | 8 / 8 | 8 / 0 / 0(0.76) | 0.58 | 0.92 | 0.78 | 分離 | | construction-placement-by-purity | 5 / 5 | 5 / 0 / 0 | 0.41 | 0.91 | 0.68 | 分離 | | construction-separate-from-execution | 4 / 4 | 4 / 1 / 0 | 0.67 | 0.92 | 0.81 | 分離(fit で fp 解消) | | error-message-names-operation | 4 / 5 | 4 / 0 / 0 | 0.20 | 0.95 | 0.61 | 分離,blind | | fixed-choices-use-enum | 4 / 5 | 4 / 0 / 0 | 0.08 | 0.92 | 0.5 | 分離,blind | | fixture-justified | 4 / 4 | 4 / 0 / 0 | 0.13 | 0.94 | 0.54 | 分離,blind | | frozen-base-model-sets-all-settings | 5 / 4 | 5 / 0 / 0 | 0.04 | 0.95 | 0.5 | 分離,blind | | frozen-model-subclass-keeps-locked-settings | 4 / 5 | 4 / 1 / 0 → 4 / 0 / 0 | 0.56 → 0.06 | 0.89 → 0.94 | 0.5 | 書き直しで分離,blind | | function-single-purpose | 3 / 4 | 3 / 0 / 0 | 0.48 | 0.76 | 0.62 | 分離 | | import-name-self-explanatory | 5 / 5 | 4 / 1 / 1 → 5 / 0 / 0 | 0.53 → 0.30 | 0.46 → 0.82 | 0.57 | 書き直しで分離,blind | | json-parse-uses-model-validate-json | 3 / 5 | 3 / 0 / 0 | 0.25 | 0.94 | 0.62 | 分離,blind | | known-defect-marker-names-removal | 4 / 4 | 4 / 0 / 0 | 0.24 | 0.80 | 0.52 | 分離,blind | | no-comment-restating-code | 3 / 5 | 3 / 0 / 0 | 0.30 | 0.86 | 0.59 | 分離,blind | | no-exposed-mutable-collection | 3 / 5 | 3 / 2 / 0 → 3 / 1 / 0 | 0.86 → 0.93 | 0.80 → 0.96 | 0.5(据え置き) | 書き直し後も分離しない(advisory のまま) | | no-reaching-through-collaborators | 4 / 3 | 4 / 2 / 0 | 0.73 | 0.84 | 0.79 | 分離(余白は狭い) | | plain-class-defines-slots | 3 / 5 | 3 / 2 / 0 | 0.77 | 0.97 | 0.89 | 分離(fit で fp 解消) | | repeated-tests-use-parametrize | 3 / 3 | 3 / 1 / 0 | 0.50 | 0.78 | 0.66 | 分離(fit で fp 解消) | | string-literal-is-named-constant | 4 / 3 | 4 / 0 / 0 | 0.25 | 0.66 | 0.47 | 分離 | | value-object-is-immutable | 4 / 5 | 4 / 0 / 0 | 0.15 | 0.89 | 0.53 | 分離,blind | 書き直した 3 規則は,ユーザーが 1 回だけ再 eval(`--accept`)した結果で書いている(矢印の右側).これ以上の再実行はしない方針なので,分離しない規則は advisory のまま限界を記録する. ## 昇格の候補(この回では昇格しない) ADR-0021 の昇格条件は「fixtures で偽陽性 0」と「リポジトリ自身のファイルで偽陽性 0」の両方を満たすことである.後者はキーが必要なため測っていない.下表は前者を満たし,余白が pass ごとのばらつきより広い規則である.リポジトリ全体での実行で偽陽性 0 を確かめてから昇格させたい. | 規則 | 昇格すると消せる文章 | | --- | --- | | command-query-naming | AGENTS.md「name command functions for their side effects and query functions for the value they return」 | | function-single-purpose | AGENTS.md「Keep functions single-purpose at one abstraction level」の部分(「with short variable lifetimes」は残す);python-style `code_style.md`「Keep functions focused and small」 | | no-comment-restating-code | AGENTS.md「Minimize comments and docstrings」の文のうち,コードを言い換えるコメントの部分(公開 API の docstring を求める部分は残す) | | construction-placement-by-purity | `models.md`「Use classmethods as alternative constructors for pure construction ...」とその例 | | fixed-choices-use-enum | `models.md`「Use `Enum`/`StrEnum` for fixed choices instead of raw string literals or dict maps」 | | fixture-justified | `testing.md` の `@pytest.fixture` と「Helper function」の 2 行(「Fixture scope」の行は 2 件以上で使われる fixture を規則が判定しないため残す) | | frozen-base-model-sets-all-settings | なし(`models.md` の `FrozenBaseModel` の例は書き方の手本として残す) | | json-parse-uses-model-validate-json | `models.md`「Parse JSON with `Model.model_validate_json(...)`」 | | known-defect-marker-names-removal | `testing.md`「and a comment naming the condition for removing the marker」の部分 | | string-literal-is-named-constant | `code_style.md`「define semantically meaningful string literals as module-level constants ...」の部分 | | value-object-is-immutable | `models.md`「Use `@dataclass(frozen=True, slots=True)` for internal value objects」のうち frozen の部分(`slots=True` は残す) | | error-message-names-operation | なし(python-style に対応する文章がない) | 候補にしない規則: - construction-separate-from-execution,no-reaching-through-collaborators,plain-class-defines-slots,repeated-tests-use-parametrize:0.5 では偽陽性があり,fit 後も clean との余白が 0.1〜0.15 しかない. - no-exposed-mutable-collection:書き直し後も分離しない(最高 clean 0.93,最低 bad 0.96). - import-name-self-explanatory,frozen-model-subclass-keeps-locked-settings:書き直しで分離したが,書き直し後の eval が 1 回だけなので,次の回で確かめる. 昇格したときに AGENTS.md から消せる文(親セッションが全レーン完了後に扱う):「name command functions for their side effects and query functions for the value they return」,「Keep functions single-purpose at one abstraction level」(前半),「Minimize comments and docstrings」(コードを言い換えるコメントの部分).ただし AGENTS.md は全言語共通なので,他言語の同じ規則も昇格したときにだけ消せる. ## Stop 1 回あたりの subject 数と費用 `jev-lint review --dry-run`(この branch の規則,fixtures は除外)を,マージ済み PR の状態を再現した一時 clone で実行した. | PR | Python 規則 | 全規則 | 費用見積り(全規則) | | --- | --- | --- | --- | | #201(Python 33 ファイル,+4120 行) | 984 | 988 | 約 $0.028 | | #203(23 ファイル,+2305 行) | 774 | 776 | 約 $0.021 | | #224(5 ファイル,+80 行) | 38 | 38 | 約 $0.001 | #201 で多いのは `command-query-naming`(246),`function-single-purpose`(246),`string-literal-is-named-constant`(156),`fixed-choices-use-enum`(139),`no-comment-restating-code`(115).`SUBJECT_CAP = 250` は「最大のセッションで 104」という測定を根拠にしている.規則の追加後は大きな PR がこの cap を大きく超え,後ろの tier とファイルが切られる.費用は 1000 subject でも約 $0.03 で問題にならない.したがって cap を見直すかどうかは所要時間で判断すべきだが,所要時間はキーなしでは測れない(hook のコードはこのレーンの範囲外). ## eval の費用 1 回の全 eval(19 規則,3 passes,132 requests):baseline の `spent` の合計で約 $0.011.dry-run の見積りは約 $0.010.書き直した 3 規則の再 eval:約 $0.0016(12 requests). ## Limits - `no-exposed-mutable-collection` は,private な list field を持つ不変条件のない dataclass(`CsvRow`)を違反と判定する(0.93).文脈を `located` に広げても分離しなかった.cutoff は 0.5 のままで advisory.baseline があるため `rule_tiers()` の tuned tier に入り,subject cap を先に使う.baseline を外すと `test_every_saved_eval_baseline_still_scores_as_accepted` が「baseline なし」で失敗するので外していない(review 指摘,Limits として記録). - `.ignore` は ast-grep のほかに ripgrep なども読むため,それらの検索で fixtures が出なくなる. - fixtures は規則ごとに 6〜10 件と少なく,著者がラベルを付けたもので,較正とは言えない.blind の 8 規則は境界の fixture がない. - `frozen-model-subclass-keeps-locked-settings` は,別ファイルの中間クラスを経由する `FrozenBaseModel` の子孫を判定できない(file 軸の制約). - `construction-separate-from-execution` の `main()`(`build_order_service` を呼ぶだけ)は matcher に選ばれないので,fixture に置いたが subject ではない. - ローカルの `tests/hooks` で `test_cleanup_worktrees_isolation.py::test_a_gitlink_worktree_is_skipped_without_running_submodule_git` が失敗する.sandbox 内で submodule の `git clone` ができないためで,この変更とは関係ない(CI で確認する). Refs #220 Refs #196 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <132188853+furedea@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… run With the rules fitted in #240-#244, #201 alone plans 988 subjects, far over the cap of 250. One uncached run of that diff sent all 60 planned requests, answered every subject and took 3.41 s through op (0.97 s of asking) for 0.025 USD, so 2000 holds twice it within the 90 s budget and jev-lint's token burst. The ADR now also states the run's real time limits: 90 s of the Stop and 60 s per child. Refs #220 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s under it (#246) Stop 時の model rules の subject 上限 `SUBJECT_CAP` を,実測に基づいて 250 → 2000 に上げます. あわせて,cap が効くときにキャッシュ済みファイルの finding が落ちる不具合と,1 ファイルも cap に入らないと差分全体を送ってしまう不具合を直します. 当初含めていた「promote 済み rule(`severity: error`)で毎 Stop ブロックする gate」は,ADR-0027(#250)の決定に従って取り除きました. Refs #220 | 項目 | 変更前 | 変更後 | | --------------------------------------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------- | | `SUBJECT_CAP` | 250 | 2000 | | cap で他のファイルが外れるとき,全 subject がキャッシュ済みのファイル | judge から外れ,キャッシュ済み finding が消える | 費用 0 として必ず渡し,finding を報告する | | 1 ファイルも cap に入らず,一部がキャッシュ済み | 選択が空になり差分全体を送る(cap 超過) | 何も送らない(`0/N subjects` と報告) | | ADR-0021 の実行時間の記述 | 「A run has 60 seconds」 | Stop 内で最大 90 s(検証の使用分を差し引く),子プロセスごとに最大 60 s(planning は 20 s) | ## 検証 - [x] `uv run pytest`(全体): 6134 passed, 2 skipped(origin/main にリベース後) - [x] ruff check / ty: pass.lefthook pre-commit / commitlint: pass - [x] Red → Green: 全件キャッシュ済みファイルのテストは,実装前に「差分全体を送る」理由で失敗 - [x] Red → Green: 1 ファイルも cap に入らない場合のテストは,実装前に `op` が呼ばれて失敗 - [x] Red → Green: `test_the_subject_cap_holds_the_largest_measured_session_whole` を 988 subjects に更新すると,250 で失敗 - [x] CI: push 後の結果は下のチェック欄を参照 ## 計測(`SUBJECT_CAP` の根拠) - 条件:2026-11-18,`jev-lint` 0.7.0,model `jev-1.14.0`.#201 のマージコミット `db7226d0` を `--base 746cd48` で review.`-R agents/hooks/lint/model-rules`(#240–#244 後の全ルール,ADR ルールを含む),新規キャッシュ,concurrency は既定の 32,`op run` 経由 - 計画(dry-run): 988 subjects,60 requests,cached 0,約 $0.028 - 実測(**1 回のみ**のためばらつきは不明): real 3.41 s(user 2.70 s,sys 0.18 s),exit 0 - 記録ファイル(`--record`)との照合:送信は 60 requests で計画どおり.988 subjects すべてに回答があり(欠落 0),retried・rateLimited・splits はいずれも 0.問い合わせ区間の `wallMs` は 969 ms(リクエスト時間の合計は 20.2 s),入力 583,810 tokens,$0.0245 - 参考:同じ差分を全件キャッシュ済みで実行すると(ネットワークなし),3 回とも 0.17–0.18 s - 判断:2000 は #201 の 2 倍超を丸ごと収める.1 subject ≈ 590 tokens なので,cap いっぱいでは jev-lint の token burst(1.2M)の約 98% になり,超過分のペーシングは最大でも約 6 s.実測の 10 倍でも 90 s 予算の 70%(63 s)を大きく下回る.計測が 1 回だけなので,数値そのものではなく余裕幅で判断した <details> <summary>範囲・除外・経緯</summary> - 範囲:`agents/hooks/lib/model_rules_run.py`(`SUBJECT_CAP`,`_capped_plan`),ADR-0021 の amendment(cap と実行時間の記述),`docs/DESIGN.md` と `docs/DESIGN_ja.md`(cap の値と根拠),テスト(`test_model_rules.py`,`test_model_rules_report.py`,`test_model_rules_tiers.py`) - 取り除いたもの(ADR-0027): exit 1 を error finding の結果として読む処理,gating finding による毎 Stop ブロック,その文言・receipt・resume 項目,`test_model_rules_gate_findings.py`,ADR-0021 への gate の追記.revert コミット 676f15e で取り除き,squash 後の差分には残らない - 除外(ブリーフに従う): model rule の promote やブロック(ADR-0027),セッションごと 1 回の報告(#245/#252),ルールファイルと cutoff,他リポジトリ - キャッシュと cap: dry-run の batches は未キャッシュの subject だけを含むため,キャッシュ済み subject はもともと cap に数えられていなかった(変更不要) - batch の `file` と渡したパスの一致:実際の dry-run(#201 の差分,34 ファイル)で,全件完全一致することを確認した - #252 との関係:#252 は `model_rules_gate.py` を変更する.本 PR は同ファイルを変更しないため,競合はない - レビュー対応(rework 後の 1 回目): - P1(Claude)「gate 機能が差分にない」: 説明を差し替える前のレビューだった.gate は ADR-0027 に従って意図的に除いたもので,タイトルと本文は絞り込み済みと返信して resolve - P2(Codex)「設計書が 250 のまま」: 5891a33 で両方の設計書を 2000 と新しい根拠に更新 - P3(Claude summary,スレッドなし)「`paths` が空のレビューでは全件キャッシュ済みファイルが残らない」: `_Changes.reviews` は `sendable` が空でないときだけ `Review` を作り,常に明示的なパスを渡すため,現状では起きない(潜在のみ).修正はせず,ここに記録する - レビュー対応(rework 後の 2 回目,修正なし): P2「対象のないパスがあると `if not chosen` を通らず,対象のないファイルだけで `op run` が起動する.`judged` にもスキップ分のキャッシュが混ざる」.dry-run だけでは対象のないファイルと全件キャッシュ済みのファイルを区別できず,後者のキャッシュ済み finding を報告するにはその起動が必要.新たな問い合わせは 0 で,誤った finding も出ない.件数表示のずれは以前からのもので advisory に限られるため,ブリーフの基準に従い返信・resolve・記録にとどめた(Limits) - 前回レビューの P3「never paced に余裕がない」は,コメントと ADR の表現を「最大約 6 s のペーシング」に直して解消した </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <132188853+furedea@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…nown at hook time (#254) ## 概要 hook の時点で確定できる事実がある `gh` 呼び出しが確認(ask)になり,lane が承認待ちで止まっていた.文字列の解析を深くせず,確定できる 3 種類だけを allow 側に直す. Closes #253 Refs #197, #181 ## 変更 - 変更 1:`-R owner/repo`(`--repo`)で対象を明示した読み取りは,作業ディレクトリの remote を理由に確認にしない(`gh_repository.names_repository_option`,`gh_invocation._classify_words`).host は `-R` の値で決まり,host 部分が無ければ github.com.github.com 以外の host,run time の値,別の option の値になりうる `-R`(直前が option)は従来どおり確認. - **glob(Issue の受け入れ条件 3 つ目)は,この PR から外した.** ユーザーの決定:hook でシェルの glob を再現する方式は収束しない(POSIX 文字クラス,`nocaseglob`,走査範囲と指摘が続いた.#200 と同じ教訓).未一致 glob の「文字どおり扱い」とそのテストを削除し,glob を含む引数(`?ref=` など)は従来どおり確認.#181 で扱う. - `-R` の許可は,行にほかのコマンドがあれば従来どおり確認(writable な PATH に git を置きうるコマンドの検査を迂回しない).`GhCall.names_repository` を足し,`gh_policy._ungranted` で行全体の検査を残した. - 変更 2:1 コマンドだけの行で,hook の環境に設定済みの `$TMPDIR` / `$HOME` だけで書かれた body / input ファイルの path は展開し,リテラルの path と同じく存在・読み取り・サイズ・秘密のスキャンにかける(`gh_options.expand_environment`,`environment_files`).未設定の変数,`$TMPDIR` / `$HOME` 以外の変数,単独の `$f`,同じ行で代入した変数,ループ,コマンド置換は従来どおり確認. - allow になる効果の区分は #201 の policy table のまま変えていない.`gh_policy.py` の変更は,`-R` の許可に行全体の検査を残す 1 行とコメントだけ.`?ref=` を含む read は #181 まで確認のまま. ## テスト - `tests/hooks/test_gh_known_at_hook_time.py`(新規):`-R` の 7 つの書き方が remote に関わらず allow,host 違い・run time の値・option に食われうる `-R`・値なし・後続の別 host の `-R` は ask,`GH_HOST` 違いは ask.glob を含む read endpoint(`?ref=`)と,`cp x later/git; gh pr list -R …` は ask. - `tests/hooks/test_gh_run_time_body_files.py`:`$TMPDIR` の body file が allow,ほかの変数・未設定・単独変数・存在しないファイル・コマンド置換・同じ行の代入・ループ・stdin のリダイレクトは ask,秘密を含むファイルは展開後に ask. - 旧仕様(`-R` でも remote を見る,環境変数の body path は ask)を確かめていた既存テストを新しい仕様に合わせた. - `uv run pytest tests`(6135 件),ruff,ty は通過. ## 記録(範囲外・前提) - 判定と実行の間の変化(TOCTOU)は範囲外.hook が見たファイルや環境変数が gh の実行時に変わりうる.#181 で扱う. - 環境変数の展開は,hook の環境の `TMPDIR` / `HOME` がサンドボックス内のシェルと同じ値を持つことを前提にする(Issue の決定).ほかの変数は値が違いうるので展開せず,確認のまま.セキュリティレビューの指摘(任意の変数を展開するとスキャン対象がずれる)はこの 2 変数への限定で対処した. - Issue の実例 4 件目の確認理由(行が変数や環境を設定する)は,この実例だけでは再現できなかった(実際の理由は「run time の file」).同じ行の代入は従来どおり確認. - ループ・関数・同じ行での変数代入・コマンド置換は緩めていない(#200,#181). - レビュー指摘(範囲外として回答・解決):フラグ直後の `-R`,`-R=値` の形,`HOME` のテスト不足.いずれも確認が 1 回増えるだけで誤った allow にはならず,read の option 表(#181)が必要. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <132188853+furedea@users.noreply.github.com> Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
…256) ## 概要 `gh` を読み取り専用のコマンドや `cd` とつないだ行は,「同じ行の別のコマンドが PATH の前の方に別の gh を置けるかもしれない」として確認になっていた.hook の時点で分かる事実(各コマンドが何も書かず別のプログラムも走らせない,リダイレクト先が PATH の要素でない,PATH に相対パスが無い)で判定し,この理由の確認をなくす.gh 自体の判定は #201 の policy table のまま. Closes #255 Refs #197, #253, #181 ## 変更 - `read_only_commands.py`(新規):語だけで「ファイルを書かず,別のプログラムも走らせない」と言えるコマンドの判定. - そのまま読み取り:`cat column cut echo false grep head jq ls nl printf pwd sleep tail tr true wc` - 語を見て判定:`awk`(`-F`/`-v` だけ,プログラムに `> | @ system getline` が無い),`sed`(`-n -E -r -e` だけ,スクリプトは行番号・パターンの `p` か `w`/`e` フラグの無い `s///`),`sort`(`-o`・`--compress-program` などを除く),`uniq`(オペランド 1 つまで),`base64`(`-d` だけ) - run time に決まる語は,そのまま読み取りの組以外と `echo`/`printf`(`printf -v PATH` になりうる)では確認. - **git の読み取りサブコマンドは入れていない**(下の「記録」参照).git を含む行は従来どおり確認. - `gh_command_line.command_line`: - `plants_nothing`:gh 以外がすべて上の読み取り(またはリテラルの `cd`)で,gh 呼び出しが 1 つ,gh 以外のリダイレクト先は `/dev/null` だけ,gh 自身の出力先は `/dev/null` か PATH の要素でないディレクトリ(run time に決まる先・PATH に相対要素があるときは不可).このとき `gh_environment._stand_in_problem` は PATH を理由に確認しない. - `directories`:hook の cwd と,リテラルの `cd` が入りうる各ディレクトリ(それまでの各ディレクトリから,bash が保つ論理パスと物理パスの両方).`cd` が失敗しても,サブシェル・パイプ内でも gh はこのどこかで動く.存在しない先,`-` で始まる語(`cd -`,`-P`,`--` など),`pushd`/`popd`,run time の先,PATH に相対・空の要素がある,`CDPATH` 下の相対の `cd`,環境の `cd` 関数は従来どおり確認. - `{ }`,`( )`,`if`,ループなど CallExpr 以外の文にリダイレクトがある行は,中のコマンドに書き込みとして記録されないので確認. - ヒアドキュメント・ヒアストリング・コマンド/プロセス/算術置換を含む行は,従来の判定(#200 の組の filter だけ)に戻す.ループ・関数・代入は従来どおり `changes_environment` で確認. - `command_objections.gh_objection`:gh 呼び出しを `directories` の各ディレクトリで判定し,全部で allow のときだけ allow(作業リポジトリの remote,設定,プログラムの所在をそれぞれのディレクトリで見る).`hook_input.working_directory` を切り出した. - `gh_environment`:`_stand_in_problem` の条件に `plants_nothing` を足しただけ(main との差は 1 行). ## 再生(2026-11-18 14:24〜11-19 15:13 JST の確認 390 件) `issue255_replay.py` を本ブランチの hook と `origin/main` の hook に向けて実行した(`XDG_STATE_HOME` を scratch に向け,実際の audit log には書かない).390 件のうち command が無い 2 件を除く 388 件,guard_command 以外の hook による 16 件は対象外.再生環境の PATH には書き込める要素が gh より前に無かったため,実際の hook 環境(PATH 理由 74 件)を近似する「書き込める要素を先頭に足した PATH」でも測った. | | 通常の PATH | 書き込める要素を先頭に足した PATH | | --- | --- | --- | | main で確認 → 本ブランチで allow | **36 件** | **19 件** | | うち,消えた worktree への `cd` を既存チェックアウトに置き換えると追加で allow | +20 件 | +6 件 | git 読み取りを入れていた段階(43 件 / 25 件)から 7 件 / 6 件減った. 確認のまま残る内訳(通常の PATH,388 件中 allow 49 件・他 hook 16 件を除く 323 件): | 理由 | 件数 | | --- | --- | | 代入・ループ・wrapper・環境(#181) | 142 | | 別のコマンドがディレクトリ/remote を変えうる(git 全般,`python3`,`jev-lint`,`mkdir`,消えた worktree への `cd` 20 件など) | 64 | | gh 呼び出しを分類できない(run time の値など) | 28 | | 未対応の構文(`$'...'` など) | 28 | | ほかのコマンド規則(cleanup_worktrees,agent-browser など) | 24 | | rm guard | 16 | | 書き込み先(class C/D) | 12 | | 送るファイルの横に別コマンド | 9 | 書き込める PATH の場合は,確認のまま 260 件が PATH 理由で出る.その内訳(通常の PATH での理由)は,代入・ループ 129,別コマンド 64,gh 呼び出しが複数(通常の PATH なら allow)30,分類不可 24,class C/D 7,送るファイル 6. 新たに allow になった 36 件はすべて目視で確認した:gh 以外は `grep/head/tail/jq/awk '{print ...}'/sed -n/sort/uniq/ls/cat/sleep/echo/wc/base64 -d`,リテラルの `cd`(`/tmp`,相対の `tests/hooks`→`../..`),`2>/dev/null` と `2>&1` だけ.gh はすべて読み取り(`pr view/list/checks/diff`,`run view/list/watch`,`issue view`,GET の `gh api`/`api graphql` query)で,#201 の policy table で許可される操作. ## テスト - `tests/hooks/test_gh_joined_read_only_lines.py`(新規,書き込める PATH 要素を gh より前に置いた状態で): - allow:Issue の例 `gh pr checks 240 -R … 2>&1 | grep -c pass`,`/dev/null` への出力,`awk | sort | uniq -c`,`sleep`/`echo`,`ls`/`wc`,`sed -n` の行番号・パターン,`base64 -d`,PATH 外への gh の出力. - 作業リポジトリを読む gh は,読み取りだけの行でも remote が github.com 外なら確認. - 確認のまま:`cp x later/gh`,`cp x later/git`(Issue の例),`mv`,`ln`,`install`,`chmod`,`export PATH=`,PATH の要素へのリダイレクト(gh 自身の出力も),run time のリダイレクト先,ほかのコマンドの `echo x > notes.txt`・`>> .git/config`,`sort -o`/`-uo`/`--compress-program`,`uniq` の出力ファイル,`awk` の書き込み・`system`・`-f`,`sed w`/`-i`,`base64 -o`,`printf $OPT PATH /tmp`,`echo $WORDS`,`{ echo x; } > later/gh`,`(echo x) > later/gh`,`if …; fi > later/gh`,`{ echo x; } >> .git/config`,`git status`,`git log`,`git commit`,`python3`. - `cd`:github.com のチェックアウトへの `cd` は allow,github.com 外へは確認(`-R` 付きなら allow),cwd 側が github.com 外なら確認,存在しない先・`$DIR`・`cd -`・`cd -P`・`pushd`・`cd -- -foreign`・symlink 越しの `cd ..`・`CDPATH` 下の相対・環境の `cd` 関数・PATH の相対要素(`.`,空)は確認. - ヒアドキュメント,ヒアストリング,`$(...)`,`<(...)`,ループ,関数,代入の行は確認. - ゲートを外す・修正前のコードに戻すとこれらのテストが失敗することを確認した(ヒアドキュメント/置換,`cd --`,symlink,`-P`,run time の `printf`/`echo`,まとまりへのリダイレクト). - `tests/hooks/test_read_only_commands.py`(新規):`writes_nothing` の単体テスト(`sort -t -o`,`sed -e p -e 'w out'`,`awk -v x=1 -F: …`,`git log`/`git status` は読み取りに入らない,など). - 既存の `test_gh_targets.py`(`gh … && gh …` は確認,`printf x > .git/config; gh pr list` は確認など)は変更なしで通過. - `uv run pytest tests`(6220 passed,2 skipped),`ruff check`,`ruff format --check`,`ty check`,`deptry`,`vulture` を通過. ## 記録(範囲外・前提・限界) - **git 読み取りは #181 に回した**(受け入れ条件 1 つ目の「読み取りの git サブコマンドを含む」から外れる).レビューで,git の読み取りがリポジトリ設定(textconv,`diff.external`,filter,fsmonitor,`gpg.program`,`hook.*`,`core.alternateRefsCommand`),`post-index-change` フック,submodule(gitlink),環境(`GIT_PAGER`,`GIT_EXTERNAL_DIFF`,`GIT_CONFIG_*`),promisor remote の遅延 fetch などからプログラムを走らせうる指摘が直すたびに続き,#200 と同じく収束しなかった.ユーザー判断(どちらでも可)を受けて親セッションが「外す」を選んだ.git を含む行は従来どおり確認になり,そのための設定検査も削除した.減る件数は通常の PATH で 7 件,書き込める PATH で 6 件. - Issue の受け入れ条件 3 つ目(リダイレクト先は `/dev/null` と PATH 外を許す)より厳しくした:PATH 外を許すのは gh 自身の出力だけで,gh 以外のコマンドは `/dev/null` だけ.書いたファイルが同じ行の後のプログラムの設定になりうるため(自動セキュリティレビューの指摘). - 判定と実行の間の変化(TOCTOU)は範囲外:hook が見た PATH の要素・`cd` 先・設定が実行時に変わりうる(同じ行のコマンドは書かないが,並行する別プロセスは書ける).#181 で扱う. - `cd` は「gh が cwd と各 `cd` 先のどれで動いても allow」とした.`cd 先` だけで判定する Issue の文言より厳しく,cwd の remote が github.com 外の場合は `cd` しても確認になる(構文から `cd` の成否・サブシェルを読まずに済ませるため). - gh 呼び出しが 2 つ以上の行は,PATH に書き込める要素がある環境では従来どおり確認(`gh repo clone`/`run download` が後の gh の前に置きうるため).書き込める PATH の再生で 30 件がこれで残る. - **レビュー最終回で出た指摘は直さずに残した(後続で扱う)**: - P1:静的な `printf` の `%n` は引数名に文字数を代入する(`printf x%n PATH` で PATH が `1` になる).書き込める PATH 要素がある環境では誤った allow になりうるので,最初に直す項目(対処案:`%n` を含む `printf` を読み取りに数えない). - P2:zsh の 2 オペランドの `cd OLD NEW` を追跡していない(対処案:オペランドが 2 つ以上なら追わない). - P2:gh のリダイレクト先のブレース展開(zsh の MULTIOS)と `~+`/`~-` を run time の先として扱っていない(対処案:`literal_words.EXPANDING_TEXT` を再利用する). - MEDIUM(ローカルの自動セキュリティレビュー):コマンドの無い文のリダイレクト(`> f` 単独)を,まとまりへのリダイレクトと同じく扱っていない(対処案:`Cmd` が引数のある CallExpr でない文の `Redirs` をすべて書き込みとみなす). - 誤検知として残るもの(確認が増えるだけで誤った allow にはならない):`awk` の比較 `>`,値を取る `uniq -f N`,一覧に無い `sort` の option,`base64` のファイル入力,`cd -P`. - レビュー対応:GitHub のスレッドはすべて返信して解決した(修正またはこの git 読み取りの除外で対処).ローカルの自動セキュリティレビューの指摘(他コマンドの書き込み,gitlink の submodule,promisor の遅延 fetch)も,書き込みの制限と git 読み取りの除外で対処済み. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <132188853+furedea@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
ghの判定を正規表現の書き方から「効果」へ切り替えた.呼び出しを (対象 repo,操作,効果) に変換し,agents/hooks/rules/gh_policy.jsonの grant(対象 × 操作 × 判定)で決める.2026-11-14 に確認になった gh 呼び出しのうち,完全な形で再現できるものは,3 件(意図どおり確認)と実行時パスの本文ファイルを使うもの(GitHub Gateway まで確認)を除き確認なしになる.
決定済みの判断事項:(1) node ID で対象を辿れない
resolveReviewThread/unresolveReviewThreadは許可する(書き込む本文がなく漏洩経路にならないため).(2) 実行時パスの本文ファイル(--body-file $TMPDIR/...など)を hook の環境で展開して走査する案は差し戻し,GitHub Gateway(#181)ができるまで確認に戻した(理由は下の「既知の限界」).リテラルパスの本文ファイルの走査と許可は維持.flowchart TD C[gh 呼び出し] --> P{allow prefix が承認?} P -- いいえ --> PV[provider の ask/deny に任せる] P -- はい --> H{行が別ホスト変数や隠れたコードを含む?} H -- はい --> ASK[確認] H -- いいえ --> K{分類できる?} K -- いいえ --> ASK K -- はい --> T[対象: trusted / untrusted / unresolved / node] T --> G{grant が対象×操作を許可?} G -- いいえ --> ASK G -- はい --> S{送る内容に秘密?} S -- はい --> ASK S -- いいえ --> OK[許可]gh pr view $n ...,gh run list --commit $(...)など読み取り--body-file $TMPDIR/...,-F body=@"$f.new"で自分の repo に書き込み--body-file body.mdなどリテラルパスは秘密スキャンを通れば許可-f body="...\x`..."`(エスケープ済み)の review 返信resolveReviewThread/unresolveReviewThread--repo other/r,別ホスト,行内で変数を代入・export・宣言する行(GH_REPO=x gh ...,env HTTPS_PROXY=x gh ...など),複数コマンド行の暗黙 repogh pr createなどは形を問わず許可pr review --approve,pr close -d,--delete-last,api -X DELETE/PUT .../mergegh run rerun/run cancel,gh stack全般gh run download.gitや dot ディレクトリ,絶対パス,..,リンク経由以外)を-Dで指定した場合だけ許可.それ以外は確認(fork の PR が作った artifact が.git/hooksや既存スクリプトを上書きしうるため)BASH_FUNC_gh・GH_FORCE_TTY・github.com 外のGH_HOST/GH_REPO,作業ツリーや一時ディレクトリにあるgh,単一呼び出しでない行で gh より前に書き込み可能な PATH エントリ--web,--editor,--fill*,--recover,本文やタイトルのない create/comment,変更のない edit--body "$BODY",--label "$X",--body "$(cat .env)",実行時に option になりうる位置引数,repo clone -- <git options>検証
uv run --frozen pytest:全体 passed(レビュー対応後も再実行)新規
tests/hooks/test_gh_effects.py:実ログの許可・確認ケース,対象解決(remote 全件・GH_REPO/GH_HOST・cd・wrapper・同一行の remote 変更),C/D の隣接形,秘密スキャン(書き込み・読み取り・heredoc・ファイル),policy 表の不正形で deny新規
tests/hooks/test_graphql_document.py:alias,文字列内の括弧,コメント,fragment,構文エラー既存のすり抜け対策
test_guard_bypasses.py・test_guard_transformations.pyは無変更で通過(ask prefix は provider に任せる)agent-harness install/verify(nix develop)成功,レンダリング済みguard_command.pyで実コマンドを確認lefthook(ruff,ty,ls-lint ほか)通過
レビュー指摘に対応(初回 6 件,再レビュー 1 回目 12 件,2 回目 6 件.CodeQL は合成サンプル,読み取りの検索クエリは送信先が GitHub のみのため変更なし)
環境変数の指摘(バックグラウンドのセキュリティレビュー)に対応:行内で変数を代入・宣言・export する,read/printf -v/for/source/eval を含む,env で環境を変える行の gh 呼び出しはすべて確認.
tests/hooks/test_gh_environment.pyで 14 変数 × 7 形式 × 読み書き,その他の形,許可のままの隣接形を確認再レビュー 3 回目の 12 件はレビュー上限のため未対応(下記 follow-up)
再レビュー 4 回目の 7 件(セキュリティ)に対応:
/dev/stdin等を標準入力として判定,http://の api URL,実行時のオプション語・URL・endpoint,送信パスの実パス解決と非通常ファイル再レビュー 5 回目の 6 件に対応:FIFO 等の非通常ファイル,
gh-resolved,単一呼び出しの実行時パスを hook 環境で展開して走査,-fの@,pr create --fill*(1 件は環境ルールで既に確認のため変更なし)再レビュー 6 回目のセキュリティ 3 件に対応:読み取りのコマンド置換,
--headのないpr create,--editor以降のセキュリティ指摘に対応(344a611, dc51f44):リテラルの
--head必須,読み取りは素のパラメータのみ,走査上限超過のファイル,未定義変数の展開,本文オプション必須,--recoverさらに 10daf8f, d1e713e, 8b098e5 で対応:
pr reviewのアクション必須,引数パスの~を展開しない,< /dev/stdin,issue/pr createのタイトル必須,stack submit --auto必須,repo clone/pr checkoutのホスト検査,必須オプションは最後の値で判定6ea9c0e, 48fa7c5:Issue 参照オプション(
--parentなど)を表で専用の種類に分け,番号以外の参照(URL,OWNER/REPO#N,実行時の値)を対象 repo として判定ed1fdc8, 3de3e6f, 8b04614, e7ca999:参照先を主対象と分離,api クエリ文字列の展開,
trap/alias,引数なしcatは引用付き heredoc のみ,計算された本文パス,hook 環境のGH_HOSTで読み取りも確認,展開値の走査,単一引用を保つパス展開,heredoc に続くリダイレクトの検出f7325cf〜bf943ff:
--branch-repoを参照先扱い,RESTsub_issuesを確認に,HOST/OWNER/REPO引数,hook 環境のGH_REPOのホスト,展開値の走査を全行に,クォート連結後の引数も走査,展開できない実行時パスは確認,gh-resolved=baseは未解決,読み取り・ローカル操作は常に作業リポジトリの remote ホストを検査(出力フィルタ以外が同じ行にあれば確認),gh stack push/submit/syncは確認,printf/echo -eのエスケープと未引用 heredoc の\は確認6c8151d〜最新:置換は語全体が 1 つの単純コマンドの置換に限る,
printfは書式 1 つで%なし,run rerun/run cancelは確認,run downloadは local,issue develop --listも読み取り検査,パス指定のecho等は不可,関数定義は環境変更,行内全コマンドの引数も走査,リダイレクト付きフィルタは remote 判定を無効化,展開後に-や/devになる実行時パスは確認3ed3d52〜最新:api endpoint の置換・パラメータ演算,
issue/pr editは変更オプション必須(required_any),本文用catは書き換え不能なシステムの実体のみ,必須オプションは別名組の最後の値,読み取りの分割されうる語,pr checkout --recurse-submodules,出力を書くsort/uniqを除外環境変数の指摘:行内で変数を代入・宣言・export する行,
read/printf -v/for/source/eval/trap/aliasを含む行,wrapper や入れ子スクリプト経由の行,hook 環境のGH_HOST/GH_REPOが github.com 外の場合はすべて確認(tests/hooks/test_gh_environment.py)5d9e7bf〜fe3ab6a8(main へ rebase 後のハッシュは変わる):hook 環境に
BASH_FUNC_があれば確認,判定時に存在しない送信ファイルは確認,ソケット設定は gh config get でも確認,REST の PR 作成でissueを指定すると確認,GH_PAGER/PAGERは固定済みの less/more/cat と短いフラグのみ,clone はcore.askPassでも確認,zsh のemulate/schedを含む行は確認,gh auth setup-gitの helper は許可,listing ルールで省けるのは方針表の分類と grant のみ(行内の環境変更・送信ファイル走査は維持),project ルールが gh を governed にしても方針表を置き換えない,gh 設定の pager とLESS/LESSOPEN等も検査,enable/disable/zmodload/autoloadを含む行は確認,zsh のnoglob/nocorrect/-,fc/r/historyを含む行は確認,builtinを含む行は確認,symlink で agent 範囲を指す gh 設定ファイルで確認,秘密走査の rg は--no-config,remote.*.vcs設定で確認,hosts.ymlや引用された値を含むhttp_unix_socketを検査,環境検査をgh_environment.pyに分離,gh の設定ディレクトリが agent の書き込み範囲にある場合とhttp_unix_socket設定で確認,credential helper は引数なし(gh のauth git-credentialを除く),git config は-zで読む,gh・git・ssh・rg・git-lfs は実体と全祖先が書き換え不能な場合のみ信頼,clone の filter は git-lfs の既定値のみ,credential helper は!・shell 構文・書き換え可能なプログラムで確認,--attachの#(代替テキスト)で確認,clone は fsmonitor のプログラム・core.alternateRefsCommandでも確認(filter は agent 範囲外に導入済みのプログラムなら許可),clone はfilter.*.smudge|process設定でも確認,GIT_ALLOW_PROTOCOLで確認,url.*.insteadOf・protocol.*設定で確認,GIT_SSH_COMMANDは未設定・ssh・sandbox runtime の値のみ許可,repository URL は https/ssh のみ,wrapper(xargs 等)の裏の gh は allow prefix がなくても判定して確認,GIT_SSH・ssh 以外で始まるGIT_SSH_COMMAND・GIT_EXEC_PATHなどの git 上書き変数とcore.sshCommand/core.gitProxyで確認,issue develop --checkoutを表から外す,clone はテンプレート・core.hooksPathがあれば確認,gh が起動するsshも gh・git と同じ PATH 検査,REST の issue 書き込みでparent_issue_id・実行時のキー・--input本文は確認,作業ツリー内のrgで確認,読み取りの引用パラメータを hook 環境で展開して別ホスト・オプションを確認,gh-resolved=baseは設定先 remote として扱う,remote 参照と gh が起動する git も gh と同じ PATH 検査,heredoc 後の行継続リダイレクト,BASH_ENV/ENV/ZDOTDIRで確認,pr checkoutは PR 由来の git hook を起動しうるため表から外して確認にmain(feat(hooks): block edits on static rule errors and guard ast-grep-ignore #203 fix(lint): close blocking ast-grep rule gaps recorded in #196 #216 fix(hooks): judge a cell turned into code from scratch and ignore attribute reasons #224 ほか)へ rebase.CodeQL の失敗 4 件(
py/clear-text-storage-sensitive-data)は,テストが公開の合成サンプルを一時プロジェクトのファイルへ書く箇所で,実害のない誤検知.CodeQL が名前にsecretを含む値を機密とみなすため,fixture 名をsecret_samplesからscan_samplesに改め(e70d0523),CodeQL は通過.フルスイート 6011 passed(main の jev-lint モデルルールテストを含む)最終レビューの 1 件(対話中の pager で
!を打てばシェルを起動できる)は変更なし.キー入力は端末の前の人だけができ,agent のコマンドは TTY なしで動くため,agent から到達できる経路ではない.LESSSECURE=1を必須にすると利用者自身のPAGER='less -R'で全 gh 呼び出しが確認になる項目 3・14 の決定を反映(ff74e999〜a7c820d1):
run downloadは信頼 owner のみ,単独の呼び出しで新しいリテラルの相対-Dに限る.同じラウンドの指摘で,clone は http の proxy・TLS 設定で確認し,宛先を新しいサブディレクトリに限る.未引用パラメータは値に空白・glob 文字を含むかシェル管理変数なら分割扱い,展開後に/proc・/devを指すパスは確認,Bash が起動時に再設定する変数も予測不能として扱う決定 (2) を差し戻し(8083df1f):実行時パスの本文ファイルは hook の環境で展開せず確認に.ログの実行時パス 10 件は
tests/hooks/test_gh_run_time_body_files.pyで確認になることを,リテラルパスは許可のままであることを確認.フルスイート 6058 passed判断事項の決定を反映(cf14569f〜385125ab):実行時パスは hook 環境で展開できて読める実ファイルのみ走査して許可.未設定・シェルが自ら設定する変数(
SECONDS,RANDOM,SHLVLなど)・位置/特殊パラメータ・zsh の$+nameを含むパスは確認.listing ルールの形でも分類できない呼び出しに実行時の値があれば確認Limits
'gh''p_…'),printfのエスケープ変換,未引用 heredoc のバックスラッシュ改行がこれに当たる.直さない(決定事項).うっかりの貼り付けはこの形にならず,意図的な隠蔽への対策は sandbox と送信先側に任せる.既知の限界(Gateway で解消)
次の 5 件は直さない.1〜3 は,sandbox 内で動く hook が自分の検査する環境を信用していることに起因する.#181 の GitHub Gateway(credential を sandbox の外へ出し,
gh_policy.jsonで判定する)で解消する.4・5 は安全側の誤判定.gh run download -Dの差し替え競合(Codex 指摘,gh_options.py):-Dは hook で一度だけ確かめるため,前の呼び出しで起動したバックグラウンドプロセスが判定後に-Dをリンクとして作ると,artifact を.gitなどへ展開できる.HTTPS_PROXY・SSL_CERT_FILEなどの環境変数(Codex 指摘,gh_environment.py):hook は自分の環境の proxy・CA 設定を検証しておらず,agent が書ける CA ファイルや proxy を gh が使いうる.TMPDIRなどが違う件(Codex 指摘,gh_policy.py):sandbox 内のシェルのTMPDIR(例:/tmp/claude-501)と hook の値が異なり,hook の環境で展開して走査したファイルと gh が送るファイルがずれうる.git@github.com:owner/repo)を repository として解析できない(Codex 指摘,gh_repository.py):確認が増えるだけの誤判定で,Limits と同じ扱い(follow-up 31).gh_policy.py):-b '$GH_TOKEN'は変数名をそのまま送るが,hook の環境に実トークンがあると誤検出して確認になる.確認が増えるだけで禁止操作は通らない.決定 (2) の差し戻し:3 のずれにより,hook 側の同じパスに無害なファイルを置けば,それを走査して許可し,gh は未走査の別ファイルを送れる.hook の環境で展開する限り塞げないため,実行時パスの本文ファイルは Gateway ができるまで確認に戻した(8083df1f).
$TMPDIR/pr/body.mdを使う PR 作成・編集は確認になる.リテラルパスの本文ファイルは引き続き走査して許可する.Follow-up(レビュー上限で保留,別 Issue で対応)
判断が要る項目は決定済み(3 は Limits に記録,14 は対応済み,未解決の 4 スレッドは上の「既知の限界」).残りは別 Issue で扱う.
--body="$(cat .env)",-b"..."などインラインのオプション値がdynamic/spreadingを失い,展開チェックを通る(P1)(08cb7aa で対応済み)-f body=@$X:raw field の@をファイル扱いしてパラメータ展開チェックから外れる(P1)(ed89699 で対応済み)printfエスケープ・未引用 heredoc の行継続ですり抜ける件)-F /dev/stdinなど標準入力を指す特殊ファイルが通常ファイル扱いになり heredoc の展開チェックを迂回(P1)(08cb7aa で対応済み)HOST/OWNER/REPO,issue develop --list -Rの別ホスト,分割される--repo furedea/$r,動的gh api "$ENDPOINT"が別ホストに届きうる(P1/P2.sandbox のネットワーク許可リストと gh の host 別認証が sink 側で抑止)(issue develop --listと動的 endpoint 以外の別ホスト URL・--repo="$R"は 08cb7aa/0ec8b37 で対応済み)gh apiのフィールドは確認にしたが,サブコマンドの読み取り(--search "$X"など)は素のパラメータを許可したままで,両経路の不一致が残る(e7ca999 で単一呼び出しの素のパラメータを hook 環境で展開して走査するようにした)gh pr view "$(printf https://…)")は URL になりうるが許可したまま.sandbox のネットワーク許可リストと gh のホスト別ログインが別ホストへの到達を抑止(ログのgh pr view $nを許可するため)(コマンド置換は 05a3086 で確認に.残るのは単一呼び出しの素の$nのみで,値は harness の環境由来)gh api repos/{owner}/{repo}/...のプレースホルダ形式は route に一致せず常に確認になる(安全側の誤り.分岐を削除するか route を拡張)(8b098e5 で未到達の分岐を削除.プレースホルダ形式は常に確認のまま)gh_options.pyのoption X is not in the gh operation tableは単体では操作名を含まない.表示時はcannot classify this gh callとCommand:プレビューが付くため未変更.guard_command.py:55のinvalid command permissionsは main からの既存コードで対象外graphql_document.pyの構文エラー 6 件は表示時にthe GraphQL document cannot be readとcannot classify this gh callが前に付くため未変更.secret_content.py:17は壊れたルール名を示す既存文言(guard_file.pyから移動)のため未変更gh run downloadは信頼 owner の repo だけ許可し,それ以外は確認(ff74e999).加えて-Dは新しいリテラルの相対ディレクトリに限る(296b5c93, e03fe1e ほか)agents/skills/git-workflow/references/delivery.mdの CI 再実行手順(gh run rerun --failed)とcommand_permissions.jsonのgh run/gh stackの justification が,rerun/cancel/stack push を確認にした現状と食い違う(skill・prefixes レーンで整合)git@github.com-work:o/r)の remote では読み取りがすべて確認になる(安全側.エイリアス解決か明示-R時の省略を検討)$nなど分割されうる語を使う読み取りは確認になった("$n"と引用すれば許可).ログのgh pr view $n系はこのため確認に戻る.venv/bin等)が PATH の gh より前にあると,gh pr list | headのような単一呼び出しでない行は確認になる(同じ行で偽 gh を置けるため)catと出力フィルタは,PATH の実体と全祖先が書き込み不可である場合だけ信頼する.Homebrew の/opt/homebrew/binのようにユーザーが書ける場所のcatでは heredoc 本文が確認になるWEB_OPTIONは-wを含む短縮オプションの束をすべて--webとみなすため,gh run list -w ci.yml(-wは--workflow)などの読み取りも確認になる(安全側.-wが web を意味するサブコマンドに限定するか,catalog に web フラグを持たせる)gh_invocation._names_foreign_host_once_expanded)とgh_policy.shell_expandedが同じ展開を重複実装している(循環 import を避けるため.共通モジュールへ移す)gh pr checkoutは確認になった(PR 由来のcore.hooksPathの hook 対策).hook が作業ツリー外を指すことを検証できれば local として許可に戻せる--input本文は JSON を解析せず確認になる(parent_issue_id対策.リテラルの JSON ファイルならキーを検査して許可に戻せる)credential.helperやcore.fsmonitorなど git が実行するその他の設定は検査していない(作業ディレクトリの.git/configは agent が書ける.現状 harness のGIT_CONFIG_*がcore.fsmonitorを上書き).git が起動しうる設定キーの網羅的な検査は別 Issue でurl.*.insteadOf(例:https を ssh に書き換える設定)を使う環境では,すべての gh 呼び出しが確認になる(安全側.書き換え後の URL と transport を検証できれば許可に戻せる)includeIfで clone 先に別設定が読まれる場合は検査していない(include 先は通常ユーザーの設定で agent は書けない.include 先が agent の書き込み範囲にあるかの検査は別 Issue で)allowWrite(~/.local/share/pnpmなど)が PATH で gh より前にある場合も含めるには,その一覧を hook から読む必要がある~/.ssh/configなどユーザーの SSH 設定のProxyCommandは検査しない(agent は書けず読めもしない).脅威モデルに入れるなら ssh を-F /dev/nullで起動するか設定を検査する/opt/homebrew/bin)の gh・git ではすべての gh 呼び出しが確認になる(安全側).standalone home-manager の~/.nix-profile/binも同様.system_programs.is_system_programを再利用して定義を揃えるgh repo clone git@github.com:owner/repo)は repository として解析できず確認になる(安全側.URL とは別に解析する.「既知の限界」4)gh repo viewの引数検査が--jq '.a // empty'や--templateの値にも適用され,/や:を含む読み取りが確認になる(安全側.位置引数だけに限定する)範囲・前提・判断の根拠
gh pr mergeなど ask/deny prefix の形は従来どおり provider が確認する(hook の ask は Codex などで deny に変わるため).upstream含む)が trusted のときだけ trusted.hook 環境のGH_HOSTが github.com 以外なら書き込みは unresolved.$NAME($TMPDIR/x.mdなど)は harness の環境から来るだけなので 1 語として扱う.$f単独は空で消えうるので分割扱い.送る値(本文・ラベル・api フィールド)のパラメータ展開は確認,コマンド置換はリテラルか heredoc を出力するだけのときに限り可.代入・修飾子・glob・zsh の$=/$~は従来どおり分割扱い.$NAME[...],X='[...$(...)]')は確認.test_gh_run_time_body_files.py).test_zsh_expansion_flags.pyの例は書き込みに差し替え.guard_file.pyの秘密マッチャーをlib/secret_content.pyへ移動,guard_command.py/command_objections.pyに配線,tests/conftest.pyにAGENT_GH_POLICY,docs/DESIGN*.mdに 1 項目.command_permissions.jsonと未対応構文の経路は触っていない.Refs #197
🤖 Generated with Claude Code