Repository navigation
feat(hooks): block edits on static rule errors and guard ast-grep-ignore - #203
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. |
Review summaryNo blocking findings. I checked:
Tests cover the new block path (stub and real ast-grep), ordering under truncation, the provider adapter, and the new suppression forms. 🤖 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: da00ddc1a5
ℹ️ 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 No blocking findings.
What I checked and found correct:
🤖 Generated with Claude Code |
|
Codex Review: Didn't find any major issues. 👍 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". |
|
@codex review |
Review summaryNo P0 or P1 findings. One P3, posted inline. What I checked:
Finding:
Not a code bug, but it matters for rollout: this must merge after the rule audits (#190–#195, #202), as the PR body says. Otherwise any existing error-severity hit will block every edit to that file. 🤖 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: 4ed511997f
ℹ️ 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 summaryFindings: 1 × P2 (inline). No P0 or P1.
What I checked and found correct:
Not verified: I couldn't confirm that dsh, Hermes and Pi act on a PostToolUse 🤖 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: a7c4a26e01
ℹ️ 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 summaryNo blocking findings (0 × P0, 0 × P1).
Other changes I checked and found no problem in:
I couldn't confirm that dsh honors a PostToolUse |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 131306ffa6
ℹ️ 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: no P0, P1 or P2 findings. There is one P3 comment, inline. I checked these parts:
The P3: adding a blank line after a marker at the top of a file turns it into a file-wide ast-grep suppression, and the guard does not ask. Merge-order note, as the PR body says: merge only after #190–#195 and #202. |
|
Codex Review: Didn't find any major issues. 🎉 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". |
|
@codex review |
Review summaryNo P0 to P3 findings. I reviewed this read-only for correctness, security, and test coverage. What I checked:
Blocking findings: 0. |
|
Codex Review: Didn't find any major issues. Breezy! 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". |
…#202) Refs #74 計画:#74 (comment) ## 概要 static rule は違反時に編集をブロックするため,常に誤りと言える形だけを残す.曖昧な語彙のファイル名(`utils.py` など)は文脈で正当な場合があるので規則にせず,関連する文章も削除する(復元しない). - 規則:`go_no_vague_directory_name`(`rules/go/go_no_vague_directory_name.yml`,`severity: error`).`util/`,`common/` 配下の `.go` を指摘し,`message` は誤りの理由(名前から何のパッケージか分からない),`note` は修正手順(ドメイン名のディレクトリへ移し,import パスを更新する)を述べる.blocking hook(#203)が両方を表示するため.`error` の規則に `note` が無いと失敗するテストも追加した.`pkg/` は公式ドキュメントが禁じておらず,polyglot monorepo で有用なので対象にしない(Go Code Review Comments が名指しするのは util / common).`files:` の glob と `rule: {kind: source_file}` で判定する. - hook の修正(`agents/hooks/lib/static_rule_scan.py`):`files:` の glob が repo より上の祖先ディレクトリ(`~/common/` など)に一致しないよう,設定ごとの基準ディレクトリ(共有設定は repo root,プロジェクトの `sgconfig.yml` はその親ディレクトリ)から相対パスで `ast-grep` を実行する.メッセージ中のパスは従来どおり絶対パス. - テスト:`ast-grep test` のスニペットはパスを持たないため,`files:` で絞った規則はスニペット要件から外し,一時ツリーを `ast-grep scan` する別テストで検証する(指摘されるパスと,`user_store.go`,`util.go`,`pkg/store/user.go`,`internal/package/user.go` など指摘されないパス).祖先に `common`,`pkg`,`util`,`tests` があっても通常の Go ファイルを指摘しないテスト(hook のコード経由)と,入れ子の `sgconfig.yml` のテストを追加した. ## 文章と規則の対応表 | 規則 ID | 元の場所 | 元の規則(原文) | 判定 | 実装 | 例のテスト | 元の文章 | | ---------------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------- | ----------------------- | ----------------------------------------- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | | `go_no_vague_directory_name` | `go-style/references/tooling.md:17` | Do not create `pkg/`, `util/`, or `common/`; name packages by domain. | 静的(ast-grep,error) | `rules/go/go_no_vague_directory_name.yml` | `tests/test_ast_grep_rules.py`(パスの一覧) | 削除(util / common は規則が置換).「`pkg/` は有用なら使ってよい(公式は禁じていない)」の 1 行を追加(`pkg/` の禁止は撤回) | | (規則なし) | `python-style/references/code_style.md:37` | Avoid `utils.py` / `helpers.py` | 文章のまま廃止 | なし | なし | 削除(復元しない) | | (規則なし) | `typescript-style/references/tooling.md:28` | Avoid `utils.ts` and `helpers.ts` | 文章のまま廃止 | なし | なし | 削除(復元しない) | | (規則なし) | `rust-style/references/tooling.md:26` | Avoid `utils.rs` and `helpers.rs` | 文章のまま廃止 | なし | なし | 削除(復元しない) | | (規則なし) | `go-style`,`rust-style`,`typescript-style` の `references/code_style.md` | Avoid `manager`, `helper`, `util`, and `common` unless the name is already established locally. | 文章のまま廃止 | なし | なし | 削除(文ごとすべて削除.Go の `util/` と `common/` ディレクトリは規則のみで扱う) | ## 現在の hit(修正はこの PR に含めない) この PR の設定で,読み取りのみで `ast-grep scan` を実行した.`go_no_vague_directory_name`(`util/`,`common/`)の hit は 3 リポジトリとも 0 件(`pkg/` は対象外)(agent-config,agent-harness,dotfiles). ## 検証 - `uv run pytest`: 3888 passed,1 skipped(`tests/test_ast_grep_rules.py` と `tests/hooks`.全体は直前の 4861 passed,1 skipped) - `ruff check`,`ruff format --check`,`ty`,`ls-lint`(pre-commit): 通過 ## フォローアップ(レビュー上限により defer) - 非 Nix の `scripts/bootstrap_server.sh` は `ast-grep` を入れないため,その環境では ast-grep 規則すべてが届かない(この PR より前からの欠落). - `.git` も `sgconfig.yml` も無い polyglot project で,`go.mod` を持つ module の `util/` 配下に `package.json` などが共存すると,hook が `util/` 自体を基準にして `go_no_vague_directory_name` を見逃す.manifest は対象言語のものを優先する必要がある(`agents/hooks/lib/static_rule_scan.py` の `scan_root`). - Codex の指摘:Python / Rust / TypeScript の `utils` / `helpers` 行と `manager` などの文の削除を戻すべき(対応する規則が無いため).「削除する.復元しない」というユーザーの決定と食い違うため,この PR では戻さず,別 Issue で方針を確認する. ## 既知の挙動 - `go_no_vague_directory_name` は error で,既存の `util/`,`common/` を持つ repo でもその配下の編集ごとに指摘する(util / common は常に誤りとする決定による). 🤖 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>
Review summaryBlocking findings (P0/P1): 0
I also checked these and found no problems:
Limit: I couldn't run the test suite here. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0a98712aad
ℹ️ 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".
…and missing brackets A scope stopped at any next marker, even one in a comment inside an attribute, and a bracket in a string or comment closed an attribute early. Either way a lint added after it went unseen. A scope now stops only at the next marker of its own kind (in a node or not), and brackets in Rust strings and comments do not count. An attribute without its closing bracket reaches the end of the text, so lines below it count. The scope layout moves to lib/marker_scope.py to keep the guard under the file-length limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
Review summary (read-only)No findings at P0–P3 survived verification. Areas checked:
One thing I could not verify from the repo: whether the Hermes Blocking findings: 0 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afb79fb65e
ℹ️ 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".
…ts it The deadline was set when the module was imported, so a scan more than 20 seconds later, without a decision restarting it, found the budget spent and returned unknown. That broke direct scans in a slow test run. Now there is no deadline until a decision starts one, and each scan still stops after the budget. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d text - A context line that starts with `***` after a space no longer ends a patch section. - A relative path is read in the payload's directory. - Every marker in a fragment counts. - Without the scanner, a marker line's indentation counts, and in a shell script with a heredoc any changed line asks. - A marker is compared by its directive and rule list, so fixing its reason passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
Review summary (read-only) No P0–P3 findings that met the bar for reporting. Reviewed:
Noted but not flagged, because the PR states them as design decisions:
I couldn't run the test suite in this environment, so I didn't confirm it passes. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b13175e9a4
ℹ️ 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".
…destination - An editor view changes nothing, so the suppression guard skips it, as other edit-time guards do. - A NotebookEdit's new code cell is compared with the cell it replaces, in the notebook's language (Python when it names none); markdown cells and deletions add no code. - A moved file is judged only at its destination, since the source no longer exists. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
## 概要 #196 に溜まった指摘を,main に残っている blocking(`severity: error`)の ast-grep 規則に絞って整理し,規則内の局所的な 1 構文の確認で直せるものを直した.#74 の一部. 分類は次のとおり. - **a**:blocking 規則の見逃し・誤検出(規則が main に残っている) - **b**:jev-lint model rule の指摘(保留中の検証用に残す.変更しない) - **c**:obsolete(規則が削除・置換済み) - **d**:hook・文章・インフラ ADR-0021 に入れる基準(#214)は未マージのため,指示された基準をそのまま適用した.局所的な 1 構文(固定名,文字列の接頭辞,ノード種別 1 つの追加)なら規則を直す.ファイル外の情報,データフロー・スコープ,入れ子の文法の正規表現,同義の書き方を追い続ける修正が必要なものは,規則を継ぎ足さない. ## a.blocking 規則(fixture を先に足して修正) | 項目 | 分類 | 対応 | | --------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `go_no_generated_mocks`:`// Code generated by ...` ヘッダーだけの生成 mock | a 修正 | ヘッダーの接頭辞(MockGen / mockery / counterfeiter / moq / minimock)を検出 | | `go_no_context_in_struct`:`*context.Context` のフィールド | a 修正 | `pointer_type` を 1 種類追加 | | `go_use_slog`:receiver・名前付き戻り値による `log` のシャドー | a 修正 | 引数と同じ判定を receiver・result にも適用 | | `rs_no_mocking_library`:`automock` クレート,`pub use`,`use {mockall::automock};` | a 修正 | クレート一覧と `use` の接頭辞を拡張 | | `rs_no_mocking_library`:`cfg_attr` 分岐が入れ子の属性を正規表現で読む(#196 最後のコメント) | a 修正 | 正規表現をやめ,`cfg_attr` の引数トークン(カンマの直後の識別子)をノードで判定 | | `bash_readonly_constant_name`:`declare -r` を検査しない | a 修正 | スクリプト直下の `declare -r` / `typeset -r` と,関数内の `declare -gr` を追加 | | `bash_readonly_constant_name`:関数内の `readonly` を一律に除外 | a Limits | 既存の `local` を固定するだけの `readonly` と区別するにはスコープ解析が要るため,除外のまま規則の Scope に記録した(レビュー指摘で一度検査に変えたが戻した) | | `py_pydantic_base_model_only_in_frozen_base`:`pydantic.v1` 経由の回避 | a 修正 | `pydantic.v1` の素の書き方を追加 | | `go_use_slog`:関数内のローカル変数による `log` のシャドー | a Limits | スコープ解析が要る.規則の本体は精度が高く,demote すると `log.Printf` を止められなくなるため,blocking のまま規則の Limits に記録した | | `go_iota_enum_typed`:`iota + 1` などの式 | a Limits | `1 << (10 * iota)` と `iota + 1` は型なし定数の標準的な書き方で,構文だけでは enum と区別できない.既存の valid fixture のとおり対象外のまま,理由を規則に記録した | | `rs_no_follow_links`:import 別名,途中で別の型に変換するチェーン | a Limits | 別名はバインド解析が要る.変換するチェーンは該当する API を確認できていない.規則の Limits に記録した | | `py_no_pytest_asyncio`:別名 `pytest` 経由 | a Limits | バインド解析が要る.規則の Limits に記録した | | `gha_job_timeout_minutes`:`jobs` 自体が flow mapping | a Limits | 実在の workflow では使われない書き方.規則の Scope に記録した | | `gha_workflow_permissions_deny_all`:ルート全体が flow mapping | a Limits | 同上 | | `gha_pinned_uses_version_comment`:`action.yml` 内の tag 参照 | c | 規則は `action.yml` を対象に含んでいる.tag 参照は対象外と Scope に書いてある設計どおり | | `go_context_param_named_ctx` / `go_no_context_in_struct`:import path・エイリアスの確認 | c | 規則が標準 `context` を別名なしで import したファイルに限定済み | | `go_no_generated_mocks`:`//go:generate` 経由の mock | c | 規則が検出済み | 「a Limits」は,構文だけでは判定できない見逃しの端のケースで,規則は demote せず,規則ファイルの `Limits:`(または `Scope:`)に記録した.精度の高い規則は,見逃しを記録して残す.誤検出が繰り返し出る規則だけを demote する.この方針は ADR-0021 の「Which rules ast-grep may block」に 1 行足した. ## c.obsolete(規則が削除・置換済み) main に該当の規則が無いため,対応不要. - TypeScript:`ts_no_unvalidated_json_cast`,`ts_catch_rethrow_requires_cause`,`ts_no_other_test_framework`,`ts_no_vague_name`,`ts_no_home_dir_in_tests` と各 `tsx_` 版(oxlint・jev-lint へ移行) - Python:`py_async_test_anyio_marker`(削除),`py_pydantic_validate_json`,`py_plain_class_slots`(jev-lint へ降格),`py_frozen_base_model_config`,`py_frozen_base_model_no_override`,`py_definition_order`,`string-literal-is-named-constant` の `parent:` の件 - Go:`go_sealed_interface_sumtype_decl`,`go_error_no_capitalized_message` - Rust:`rs_unit_test_in_test_module`(clippy へ置換),`rs_no_path_from_format`(jev-lint へ降格),`rs_fs_call_needs_context`,`rs_no_get_prefix` - Bash / Actions:`gha_workflow_concurrency`,`gha_workflow_default_shell`,`bash_strict_mode_header`(jev-lint へ降格) ## b.jev-lint model rule の指摘(変更しない) 保留中の fixtures・eval・しきい値の当てはめで扱う.#196 のコメントに記録済みで,この PR では触れない. - `no-exposed-mutable-collection`,`no-comment-restating-code`,`no-reaching-through-collaborators`,`construction-separate-from-execution`,`function-single-purpose`(#191,4 言語) - `error-handled-once`(#190),`fixture-justified`,`frozen-model-subclass-keeps-locked-settings`,`json-parse-uses-model-validate-json`(#192) - Rust の advisory 規則:`conversion-and-query-names-follow-rust-convention`,`serde-types-follow-config-conventions`,`public-types-protect-invariants`,`domain-states-are-enums`,`paths-are-joined-not-formatted`(#193) - Bash / Actions の advisory 規則(#194),TypeScript の advisory 規則(#195) - `test_main_is_thin_selects_func_main_of_package_main` が `command-query-naming` に指摘される件(誤検出と見ている.model rule の判定の話) ## d.hook・文章・インフラ | 項目 | 分類 | 対応 | |---|---|---| | worktree の未追跡 `agents/skills/.claude/` を skill と読み,`tests/test_workflow_skill_layout.py` が失敗する | d 解決済み | main に同じ修正が入っていた(#216 の rebase で採用) | | Stop の `SUBJECT_CAP`(20)で判定が漏れないようにする | d 解決済み | 現在は 250 で,実測の上限を下回らないことをテストが保証している | | 後段の review が失敗すると,同じ指摘で毎ターン Stop を block する | d 修正 | 完了した前段の結果をレシートの `resume` に保存し,失敗した tier だけを再実行する.通知済みの件数(`shown`)も保存し,同じ指摘では二度 block しない | | 後段の review の失敗理由が捨てられ,`incomplete` としか出ない.`skipped_files=1` が実数でない | d 修正 | `Judgement.failure_reason` を結果の行に出し,`skipped_files` は失敗した review のファイル数にした | | 2 tier の review の順序(調整済み committed,調整済み uncommitted,未調整 committed,未調整 uncommitted)のテストが無い | d 修正 | `test_model_rules_resume.py` に順序のテストを追加 | | `scripts/bootstrap_server.sh` が ast-grep を入れない | d 修正 | ast-grep 0.42.1 を sha256 付きで固定し,dprint と同じ zip の経路で入れる(`install_zip_tool`).bats の fixture,Renovate の確認,README を更新 | | `.bats` を ast-grep で Bash として読めるか | d 対応しない | `languageGlobs`(`bash: ["*.bats"]`)で読めることは確認したが,Bash の規則は `.bats` に有効化しない.`@test` ブロックは Bash の文法ではなく,読めても `readonly` や関数名の規則が意図しない形で当たる.hook の `EXTENSIONS` と整形の対象も広がる | | `severity: error` を hook の block 判定に結びつける | d 範囲外 | #203 の範囲 | | Rust `tooling.md` の package-level guard,Go の `t.Parallel()` の文章 | d 対応しない | テンプレートの linter が既に覆っているため,文章は戻さない | | `types.md` の `to_owned()` / `String::from`,`package_design.md` の `pub`,`types.md` の exhaustive match,`errors.md` の `# Panics` の文章 | d 対応しない | 同上(テンプレートの linter が覆う分は戻さない) | ## 検証 - ast-grep の規則テスト:28 件通過,bats:81 件通過(ast-grep の固定を追加) - `uv run pytest`:5198 件通過,4 件失敗.失敗はいずれも model rule の subject 選択テスト(`test_main_is_thin_selects_func_main_of_package_main` など)で,この PR を外した main でも同じく失敗する(この環境での既存の失敗.CI の `test` job は通る) - `ruff check` / `ruff format --check` / `ty`:通過 Refs #74, #196 🤖 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>
レビューの要約ブロッキングの指摘:なし(P0:0,P1:0). 確認した範囲:
この PR の本文がすでに挙げている制限(ast-grep が無いときの行単位の推測,正規表現で近似した指示の書式,信頼できないリポジトリの |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12bacd938c
ℹ️ 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".
…ribute reasons (#224) ## 概要 #203 で「マージ後すぐ直す指摘」として後回しにした,抑制ガードの 2 件を直す. - **markdown セルを code セルに変える NotebookEdit**([#203 のスレッド](#203 (comment))) - 以前は,元のセルが markdown でも,その本文を比較元にしていた.そのため,元の本文にあった `# noqa` などが「変わらないマーカー」に見え,確認なしで code になっていた. - 元のセルが code でないときは,比較元を空にする.markdown の本文は何も抑制しないので,code に変えた時点でマーカーは新しいものとして扱われる. - **Rust の属性の `reason`**([#203 のスレッド](#203 (comment))) - 以前は `reason = "..."` を `reason` という語に置き換えて比べていた.そのため,理由の項目を足したり消したりするだけで確認になっていた. - `reason = "..."` の項目全体を,リストとつなぐカンマ 1 つと一緒に除いてから比べる.カンマは前のものを優先し,無ければ後ろのものを除く.句読点の横の空白は意味を持たないので,除いてから比べる. - 理由の追加・削除は承認不要になる.lint の追加は,理由と同時でも確認する. - raw 文字列の理由(`r"..."`,`r#"..."#`)も同じく除く(Codex の指摘). ## レビュー対応で直したもの - **属性の中のコメントから lint を出す抜け道**(自動セキュリティレビュー) - 範囲の文字列を畳むとき,改行も空白として畳んでいた.そのため,`// x b` を `// x` と次の行の `b` に分けると,比較用の文字列が変わらないまま `b` が lint として効いた.この抜け道は #203 の時点からあった. - さらに 1 つ目のコミットで属性の空白をすべて消したため,`// xb` を分ける場合も同じになっていた. - 範囲の改行は残す(行コメントは改行で終わるため).属性では,句読点の横の空白だけを除く. ## 検証 - `REQUIRE_AST_GREP=1 REQUIRE_JEV_LINT=1 uv run pytest --cov`(022d26f1,CI と同じ設定):5395 passed,1 skipped. - `ruff check`,`ruff format --check`,`ty check`,`ls-lint`,ファイル行数(pre-commit):通過. - 追加したテストは,実装前に失敗することを確認した. - `tests/hooks/test_guard_suppression_notebook.py`:マーカーを含む markdown セルを code に変えると確認する. - `tests/hooks/test_guard_suppression_target.py`:理由の追加,末尾・先頭・中間からの削除,raw 文字列の理由の追加・変更は通る.理由と一緒に lint を足すと確認する.属性の中のコメントの語を次の行に出すと確認する. ## 制限(Limits) どちらも安全側の誤検知(不要な確認)で,抑制をすり抜ける道ではない.この PR では直さない. - 属性の中の改行だけを変える整形(`#[allow(a,\n b)]` を `#[allow(a, b)]` にするなど)でも確認になる.行コメントを終える改行と区別せず,改行をすべて残して比べるため. - `, /* why */ reason = "kept"` のように,カンマと `reason` の間にコメントを挟むと,カンマが残って確認になる. ## 戻し方 この PR のコミットを revert する.抑制ガードの判定が #203 の時点に戻る. 🤖 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)ができるまで確認に戻した(理由は下の「既知の限界」).リテラルパスの本文ファイルの走査と許可は維持. ```mermaid 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 $(...)` など読み取り | 変数・置換で確認 | 許可(どの repo でも,github.com のみ) | | `--body-file $TMPDIR/...`,`-F body=@"$f.new"` で自分の repo に書き込み | 確認 | 確認のまま(GitHub Gateway まで).`--body-file body.md` などリテラルパスは秘密スキャンを通れば許可 | | `-f body="...\`x\`..."`(エスケープ済み)の review 返信 | 確認 | 許可 | | `resolveReviewThread` / `unresolveReviewThread` | 確認 | 許可(GraphQL での返信は確認) | | `--repo other/r`,別ホスト,行内で変数を代入・export・宣言する行(`GH_REPO=x gh ...`,`env HTTPS_PROXY=x gh ...` など),複数コマンド行の暗黙 repo | `gh pr create` などは形を問わず許可 | 確認(区分 C) | | `pr review --approve`,`pr close -d`,`--delete-last`,`api -X DELETE`/`PUT .../merge` | 一部許可 | 確認(区分 D) | | `gh run rerun`/`run cancel`,`gh stack` 全般 | 許可 | 確認(外部で走るジョブ,検証されない拡張の実行,未走査のコミットを戻せないため) | | `gh run download` | 許可 | 信頼 owner の repo から,単独の呼び出しで,どの部分もまだ存在しないリテラルの相対ディレクトリ(`.git` や dot ディレクトリ,絶対パス,`..`,リンク経由以外)を `-D` で指定した場合だけ許可.それ以外は確認(fork の PR が作った artifact が `.git/hooks` や既存スクリプトを上書きしうるため) | | 環境の `BASH_FUNC_gh`・`GH_FORCE_TTY`・github.com 外の `GH_HOST`/`GH_REPO`,作業ツリーや一時ディレクトリにある `gh`,単一呼び出しでない行で gh より前に書き込み可能な PATH エントリ | 許可 | 確認(gh 以外のプログラムや別ホストが動きうるため) | | `--web`,`--editor`,`--fill*`,`--recover`,本文やタイトルのない create/comment,変更のない edit | 一部許可 | 確認(ブラウザ・エディタ・対話入力が未走査の内容を送るため) | | `--body "$BODY"`,`--label "$X"`,`--body "$(cat .env)"`,実行時に option になりうる位置引数,`repo clone -- <git options>` | 許可 | 確認 | | 秘密情報パターンに一致する本文・ファイル・heredoc・読み取りの query | 検査なし | 確認 | ## 検証 - [x] `uv run --frozen pytest`:全体 passed(レビュー対応後も再実行) - [x] 新規 `tests/hooks/test_gh_effects.py`:実ログの許可・確認ケース,対象解決(remote 全件・`GH_REPO`/`GH_HOST`・`cd`・wrapper・同一行の remote 変更),C/D の隣接形,秘密スキャン(書き込み・読み取り・heredoc・ファイル),policy 表の不正形で deny - [x] 新規 `tests/hooks/test_graphql_document.py`:alias,文字列内の括弧,コメント,fragment,構文エラー - [x] 既存のすり抜け対策 `test_guard_bypasses.py`・`test_guard_transformations.py` は無変更で通過(ask prefix は provider に任せる) - [x] `agent-harness install` / `verify`(`nix develop`)成功,レンダリング済み `guard_command.py` で実コマンドを確認 - [x] lefthook(ruff,ty,ls-lint ほか)通過 - [x] レビュー指摘に対応(初回 6 件,再レビュー 1 回目 12 件,2 回目 6 件.CodeQL は合成サンプル,読み取りの検索クエリは送信先が GitHub のみのため変更なし) - [x] 環境変数の指摘(バックグラウンドのセキュリティレビュー)に対応:行内で変数を代入・宣言・export する,read/printf -v/for/source/eval を含む,env で環境を変える行の gh 呼び出しはすべて確認.`tests/hooks/test_gh_environment.py` で 14 変数 × 7 形式 × 読み書き,その他の形,許可のままの隣接形を確認 - [ ] 再レビュー 3 回目の 12 件はレビュー上限のため未対応(下記 follow-up) - [x] 再レビュー 4 回目の 7 件(セキュリティ)に対応:`/dev/stdin` 等を標準入力として判定,`http://` の api URL,実行時のオプション語・URL・endpoint,送信パスの実パス解決と非通常ファイル - [x] 再レビュー 5 回目の 6 件に対応:FIFO 等の非通常ファイル,`gh-resolved`,単一呼び出しの実行時パスを hook 環境で展開して走査,`-f` の `@`,`pr create --fill*`(1 件は環境ルールで既に確認のため変更なし) - [x] 再レビュー 6 回目のセキュリティ 3 件に対応:読み取りのコマンド置換,`--head` のない `pr create`,`--editor` - [x] 以降のセキュリティ指摘に対応(344a611, dc51f44):リテラルの `--head` 必須,読み取りは素のパラメータのみ,走査上限超過のファイル,未定義変数の展開,本文オプション必須,`--recover` - [x] さらに 10daf8f, d1e713e, 8b098e5 で対応:`pr review` のアクション必須,引数パスの `~` を展開しない,`< /dev/stdin`,`issue/pr create` のタイトル必須,`stack submit --auto` 必須,`repo clone`/`pr checkout` のホスト検査,必須オプションは最後の値で判定 - [x] 6ea9c0e, 48fa7c5:Issue 参照オプション(`--parent` など)を表で専用の種類に分け,番号以外の参照(URL,`OWNER/REPO#N`,実行時の値)を対象 repo として判定 - [x] ed1fdc8, 3de3e6f, 8b04614, e7ca999:参照先を主対象と分離,api クエリ文字列の展開,`trap`/`alias`,引数なし `cat` は引用付き heredoc のみ,計算された本文パス,hook 環境の `GH_HOST` で読み取りも確認,展開値の走査,単一引用を保つパス展開,heredoc に続くリダイレクトの検出 - [x] f7325cf〜bf943ff:`--branch-repo` を参照先扱い,REST `sub_issues` を確認に,`HOST/OWNER/REPO` 引数,hook 環境の `GH_REPO` のホスト,展開値の走査を全行に,クォート連結後の引数も走査,展開できない実行時パスは確認,`gh-resolved=base` は未解決,読み取り・ローカル操作は常に作業リポジトリの remote ホストを検査(出力フィルタ以外が同じ行にあれば確認),`gh stack push/submit/sync` は確認,`printf`/`echo -e` のエスケープと未引用 heredoc の `\` は確認 - [x] 6c8151d〜最新:置換は語全体が 1 つの単純コマンドの置換に限る,`printf` は書式 1 つで `%` なし,`run rerun`/`run cancel` は確認,`run download` は local,`issue develop --list` も読み取り検査,パス指定の `echo` 等は不可,関数定義は環境変更,行内全コマンドの引数も走査,リダイレクト付きフィルタは remote 判定を無効化,展開後に `-` や `/dev` になる実行時パスは確認 - [x] 3ed3d52〜最新:api endpoint の置換・パラメータ演算,`issue/pr edit` は変更オプション必須(`required_any`),本文用 `cat` は書き換え不能なシステムの実体のみ,必須オプションは別名組の最後の値,読み取りの分割されうる語,`pr checkout --recurse-submodules`,出力を書く `sort`/`uniq` を除外 - [x] 環境変数の指摘:行内で変数を代入・宣言・export する行,`read`/`printf -v`/`for`/`source`/`eval`/`trap`/`alias` を含む行,wrapper や入れ子スクリプト経由の行,hook 環境の `GH_HOST`/`GH_REPO` が github.com 外の場合はすべて確認(`tests/hooks/test_gh_environment.py`) - [x] 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 を起動しうるため表から外して確認に - [x] main(#203 #216 #224 ほか)へ rebase.CodeQL の失敗 4 件(`py/clear-text-storage-sensitive-data`)は,テストが公開の合成サンプルを一時プロジェクトのファイルへ書く箇所で,実害のない誤検知.CodeQL が名前に `secret` を含む値を機密とみなすため,fixture 名を `secret_samples` から `scan_samples` に改め(e70d0523),CodeQL は通過.フルスイート 6011 passed(main の jev-lint モデルルールテストを含む) - [x] 最終レビューの 1 件(対話中の pager で `!` を打てばシェルを起動できる)は変更なし.キー入力は端末の前の人だけができ,agent のコマンドは TTY なしで動くため,agent から到達できる経路ではない.`LESSSECURE=1` を必須にすると利用者自身の `PAGER='less -R'` で全 gh 呼び出しが確認になる - [x] 項目 3・14 の決定を反映(ff74e999〜a7c820d1):`run download` は信頼 owner のみ,単独の呼び出しで新しいリテラルの相対 `-D` に限る.同じラウンドの指摘で,clone は http の proxy・TLS 設定で確認し,宛先を新しいサブディレクトリに限る.未引用パラメータは値に空白・glob 文字を含むかシェル管理変数なら分割扱い,展開後に `/proc`・`/dev` を指すパスは確認,Bash が起動時に再設定する変数も予測不能として扱う - [x] 決定 (2) を差し戻し(8083df1f):実行時パスの本文ファイルは hook の環境で展開せず確認に.ログの実行時パス 10 件は `tests/hooks/test_gh_run_time_body_files.py` で確認になることを,リテラルパスは許可のままであることを確認.フルスイート 6058 passed - [x] 判断事項の決定を反映(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 は安全側の誤判定. 1. `gh run download -D` の差し替え競合(Codex 指摘,`gh_options.py`):`-D` は hook で一度だけ確かめるため,前の呼び出しで起動したバックグラウンドプロセスが判定後に `-D` をリンクとして作ると,artifact を `.git` などへ展開できる. 2. `HTTPS_PROXY`・`SSL_CERT_FILE` などの環境変数(Codex 指摘,`gh_environment.py`):hook は自分の環境の proxy・CA 設定を検証しておらず,agent が書ける CA ファイルや proxy を gh が使いうる. 3. hook と sandbox で `TMPDIR` などが違う件(Codex 指摘,`gh_policy.py`):sandbox 内のシェルの `TMPDIR`(例:`/tmp/claude-501`)と hook の値が異なり,hook の環境で展開して走査したファイルと gh が送るファイルがずれうる. 4. scp 形式の URL(`git@github.com:owner/repo`)を repository として解析できない(Codex 指摘,`gh_repository.py`):確認が増えるだけの誤判定で,Limits と同じ扱い(follow-up 31). 5. 秘密スキャンが単一引用符内の変数も hook の環境で展開する(Codex 指摘,`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 で扱う. 1. `--body="$(cat .env)"`,`-b"..."` などインラインのオプション値が `dynamic`/`spreading` を失い,展開チェックを通る(P1)(08cb7aa で対応済み) 2. `-f body=@$X`:raw field の `@` をファイル扱いしてパラメータ展開チェックから外れる(P1)(ed89699 で対応済み) 3. 決定済み:直さず上の Limits に記録(秘密スキャンを引用符分割・`printf` エスケープ・未引用 heredoc の行継続ですり抜ける件) 4. `-F /dev/stdin` など標準入力を指す特殊ファイルが通常ファイル扱いになり heredoc の展開チェックを迂回(P1)(08cb7aa で対応済み) 5. 送信ファイルの走査が先頭 100000 bytes のみ(P1)(dc51f44 で上限超過を確認に) 6. 読み取りの位置引数 URL・`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 で対応済み) 7. 読み取りの検索値・endpoint に入るパラメータ展開(送信先は GitHub のみ)(P2).`gh api` のフィールドは確認にしたが,サブコマンドの読み取り(`--search "$X"` など)は素のパラメータを許可したままで,両経路の不一致が残る(e7ca999 で単一呼び出しの素のパラメータを hook 環境で展開して走査するようにした) 8. stdin のリテラルファイル判定の文字種を許可リスト化し,読めないファイルは確認にする(バックグラウンドのセキュリティレビュー)(非通常ファイルは ed89699 で確認に.文字種の許可リスト化は未対応) 9. 読み取りで先頭が展開の位置引数(`gh pr view "$(printf https://…)"`)は URL になりうるが許可したまま.sandbox のネットワーク許可リストと gh のホスト別ログインが別ホストへの到達を抑止(ログの `gh pr view $n` を許可するため)(コマンド置換は 05a3086 で確認に.残るのは単一呼び出しの素の `$n` のみで,値は harness の環境由来) 10. `gh api repos/{owner}/{repo}/...` のプレースホルダ形式は route に一致せず常に確認になる(安全側の誤り.分岐を削除するか route を拡張)(8b098e5 で未到達の分岐を削除.プレースホルダ形式は常に確認のまま) 11. jev-lint(advisory):`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 からの既存コードで対象外 12. jev-lint(advisory):`graphql_document.py` の構文エラー 6 件は表示時に `the GraphQL document cannot be read` と `cannot classify this gh call` が前に付くため未変更.`secret_content.py:17` は壊れたルール名を示す既存文言(`guard_file.py` から移動)のため未変更 14. 決定済み:`gh run download` は信頼 owner の repo だけ許可し,それ以外は確認(ff74e999).加えて `-D` は新しいリテラルの相対ディレクトリに限る(296b5c93, e03fe1e ほか) 15. `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 レーンで整合) 16. ssh ホストエイリアス(`git@github.com-work:o/r`)の remote では読み取りがすべて確認になる(安全側.エイリアス解決か明示 `-R` 時の省略を検討) 17. 素の `$n` など分割されうる語を使う読み取りは確認になった(`"$n"` と引用すれば許可).ログの `gh pr view $n` 系はこのため確認に戻る 18. direnv などで作業ツリー内の bin(`.venv/bin` 等)が PATH の gh より前にあると,`gh pr list | head` のような単一呼び出しでない行は確認になる(同じ行で偽 gh を置けるため) 19. 本文用の `cat` と出力フィルタは,PATH の実体と全祖先が書き込み不可である場合だけ信頼する.Homebrew の `/opt/homebrew/bin` のようにユーザーが書ける場所の `cat` では heredoc 本文が確認になる 20. `WEB_OPTION` は `-w` を含む短縮オプションの束をすべて `--web` とみなすため,`gh run list -w ci.yml`(`-w` は `--workflow`)などの読み取りも確認になる(安全側.`-w` が web を意味するサブコマンドに限定するか,catalog に web フラグを持たせる) 21. 読み取りの位置引数を展開する処理(`gh_invocation._names_foreign_host_once_expanded`)と `gh_policy.shell_expanded` が同じ展開を重複実装している(循環 import を避けるため.共通モジュールへ移す) 22. remote の参照は PATH が見つける git が agent の書き込み範囲外にある場合だけ行う(48a56e6).作業ツリー内の git が PATH の先頭にある環境では作業ディレクトリの repo への読み書きが確認になる 23. `gh pr checkout` は確認になった(PR 由来の `core.hooksPath` の hook 対策).hook が作業ツリー外を指すことを検証できれば local として許可に戻せる 24. REST の issue ルートへの `--input` 本文は JSON を解析せず確認になる(`parent_issue_id` 対策.リテラルの JSON ファイルならキーを検査して許可に戻せる) 25. `credential.helper` や `core.fsmonitor` など git が実行するその他の設定は検査していない(作業ディレクトリの `.git/config` は agent が書ける.現状 harness の `GIT_CONFIG_*` が `core.fsmonitor` を上書き).git が起動しうる設定キーの網羅的な検査は別 Issue で 26. global の `url.*.insteadOf`(例:https を ssh に書き換える設定)を使う環境では,すべての gh 呼び出しが確認になる(安全側.書き換え後の URL と transport を検証できれば許可に戻せる) 27. git config の `includeIf` で clone 先に別設定が読まれる場合は検査していない(include 先は通常ユーザーの設定で agent は書けない.include 先が agent の書き込み範囲にあるかの検査は別 Issue で) 28. 単一呼び出しでない行での「gh より前の書き込み可能な PATH entry」検査は作業ツリーと一時ディレクトリのみを見る.sandbox の `allowWrite`(`~/.local/share/pnpm` など)が PATH で gh より前にある場合も含めるには,その一覧を hook から読む必要がある 29. `~/.ssh/config` などユーザーの SSH 設定の `ProxyCommand` は検査しない(agent は書けず読めもしない).脅威モデルに入れるなら ssh を `-F /dev/null` で起動するか設定を検査する 30. gh などの実体と全祖先が書き換え不能であることを求めるため,Homebrew(`/opt/homebrew/bin`)の gh・git ではすべての gh 呼び出しが確認になる(安全側).standalone home-manager の `~/.nix-profile/bin` も同様.`system_programs.is_system_program` を再利用して定義を揃える 31. scp 形式の SSH URL(`gh repo clone git@github.com:owner/repo`)は repository として解析できず確認になる(安全側.URL とは別に解析する.「既知の限界」4) 32. `gh repo view` の引数検査が `--jq '.a // empty'` や `--template` の値にも適用され,`/` や `:` を含む読み取りが確認になる(安全側.位置引数だけに限定する) 34. 判定後に別プロセスが既存の送信ファイルを書き換える競合(check-then-use)は防げない.gh に渡す前に内容を固定するには,走査した内容を一時ファイルに複製して渡すなどの仕組みが要る 36. 秘密パターンのファイルが無いと秘密走査が素通りになる(guard_file と同じ挙動).読み込み時に存在を確認し,無ければ gh の書き込みを確認にする <details><summary>範囲・前提・判断の根拠</summary> - 判定するのは allow prefix が承認した gh 呼び出しだけ.`gh pr merge` など ask/deny prefix の形は従来どおり provider が確認する(hook の ask は Codex などで deny に変わるため). - 書き込みの暗黙 repo は,行がその gh 呼び出しだけ(本文用の cat/printf/echo の置換は可)で,作業ディレクトリの GitHub remote すべて(`upstream` 含む)が trusted のときだけ trusted.hook 環境の `GH_HOST` が github.com 以外なら書き込みは unresolved. - 単一呼び出しで代入のない行では,リテラル部分を伴う素の `$NAME`(`$TMPDIR/x.md` など)は harness の環境から来るだけなので 1 語として扱う.`$f` 単独は空で消えうるので分割扱い.送る値(本文・ラベル・api フィールド)のパラメータ展開は確認,コマンド置換はリテラルか heredoc を出力するだけのときに限り可.代入・修飾子・glob・zsh の `$=`/`$~` は従来どおり分割扱い. - zsh の添字・算術代入で隠れたコードが走りうる行(`$NAME[...]`,`X='[...$(...)]'`)は確認. - resolve/unresolve は実行前に repo を辿れないが,取り消せる操作で,GitHub がその repo への書き込み権限を持つアカウントにしか許さない(sink)ため grant で許可.返信 mutation はどの repo にも届きうるので確認.別ホストなら確認. - 秘密スキャンはコマンド全文(inline 本文・heredoc・読み取りの query)とリテラルパスのファイル.実行時パスの送信ファイルは hook の環境で展開せず,読み取りでも信頼 owner への書き込みでも確認にする(決定 (2) の差し戻し,`test_gh_run_time_body_files.py`). - テストの期待値変更:読み取りは変数・wrapper・リダイレクトを問わず許可にしたため,旧 literal_words の gh ルール前提の ask テストを allow 側へ移した.`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` と未対応構文の経路は触っていない. - ADR は adr レーンが担当. </details> Refs #197 🤖 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> Co-authored-by: furedea-agent[bot] <343832694+furedea-agent[bot]@users.noreply.github.com>
🤖 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>
Refs #74
計画:#74 (comment)
マージ順序
言語ごとの規則の PR(#190〜#195)と #202 はすべてマージ済み.この PR は origin/main(1919b066)に rebase してある.main にある
severity: errorの規則 28 件は,すべて規則テストの対象で,noteを持っている.追加した note は無い.この PR が入ると,
severity: errorの static rule はすべて編集をブロックする.また,error の規則にはnote(修正方法)が必須になる.rebase で解決したコンフリクト
agents/hooks/lib/static_rule_scan.py:feat(lint): flag Go packages under util and common with an error rule #202 の「設定ごとの基準ディレクトリから repo 相対パスで走査する」(scan_root,cwd=root,--)と,この PR のReport(error と advice の分離),noteの表示,信頼判定を両方残した.tests/test_ast_grep_rules.py:feat(lint): migrate go-style rules to ast-grep and jev-lint rules #190 の「error の規則は note を持つ」テストが,この PR のNOTE_PATTERNを同名で上書きしていた.feat(lint): migrate go-style rules to ast-grep and jev-lint rules #190 の規則ごとのテストを残し,この PR の判定(空のブロック note も検出する)を使うようにした.checkout_ofフィクスチャをtests/conftest.pyに移した.amendedに加えた.docs(adr): record which rules ast-grep may block #214 が ADR-0021 に足した「Which rules ast-grep may block」の節は,この PR の改訂と矛盾しない.ast-grep-ignoreはもともと検査している.概要
ユーザーの決定:static(ast-grep)規則は,linter のエラーと同じくブロックする.advisory の段階は設けず,規則は「有効(
severity: error,ブロックする)」か「削除」のどちらかとする.まれな正当な例外は,理由を書いた抑制コメントで扱う.抑制コメントはエージェントが勝手に追加してはならず,ユーザーが承認する.docs/adr/0021_*.md)noteに修正方法を持つ.抑制ガードはすべてのプロバイダで動く.agents/hooks/lint_format.py,agents/hooks/lib/static_rule_scan.py)severity: errorの指摘を返したら,PostToolUse の{"decision": "block", "reason": ...}を返す.message(なぜ誤りか),note(Fix:として修正方法)を並べる.その後に 1 回だけ次の指示文を続ける:「Fix the code as shown. Do not move or split the code to avoid the rule; if a real exception is needed, add a suppression comment, which is reviewed.」NOTIFICATION_LIMIT_BYTES)に収める.advice は残りに収まる分だけ入れる.systemMessageを読むので,ブロック時は同じ文をsystemMessageにも入れる(プロバイダのプロファイルがブロックの形式も決める).static_rule_scan.py)agents/hooks/lint/sgconfig.yml)は,チェックアウトの origin のオーナーをtrusted_ownersが信頼している場合にだけ走る(AGENT_TRUSTED_OWNERSも同様).sgconfig.ymlの規則は,従来どおりどこでも走る.agents/hooks/guard_suppression.py,agents/hooks/lib/comment_nodes.py,agents/hooks/lib/patch_input.py)ast-grep-ignoreと Go の//nolintを対象に加えた.ast-grep-ignoreは.go,YAML,Nix でも検査する.ast-grep scan --stdinで言語ごとのコメントノードを探す.ブロックコメント,複数行文字列,YAML のブロックスカラー,Rust の raw string,ヒアドキュメント,JS の<!--コメントを正しく扱える.sgconfig.ymlを明示的に渡し,プロジェクトや親ディレクトリの設定は読まない.nolintは linter の一覧,noqaはコード,eslint は--の前まで,biome はコロンの前まで,Rust の属性はreason = "..."を除いた部分.理由文の誤字を直すだけなら通る.ast-grep-ignoreは,マーカーの後ろの語をすべて規則名として読むので,コメント全体で比べる.//nolint:errcheckを//nolintや//nolint:govetに変えるなど,対象の規則を減らす・変える・加える変更は,新しいマーカーと同じく確認する.noqaのコード,type: ignoreのコード,eslint の規則(複数行のブロックコメントも),allow/expectの lint,shellcheck のコードも同じ.ast-grep-ignoreはすべての規則を抑制するので,規則名の変更も確認する.文字列をコメントに変える変更(同じ行でも,前後の行の変更でも)も確認する.cwd(プロバイダがツールを実行するディレクトリ)を基準に読む.#[allow(...)]/#[expect(...)]は,Rust の文字列とコメントの中以外なら数える.マクロ本体の中も数える(展開されると効くため).Rust 以外のファイルでは数えない./*,-->と--!>,<<,YAML の|など)がある場合.<<を含むテキストの行を変えた場合(heredoc の終端は記号を持たない語なので,行からは見分けられない).insert/ Write は,ファイル全体に適用した前後で比べる(replace_all,行の一部の編集,MultiEdit の後続の手順も含む).エディタ系ツールのフィールド(old_str,new_str,file_text)も読む.置換がファイルに当てはまらないときは,マーカーを含むファイルなら確認する.*** End of Fileのチャンク,解釈できない行,完全一致が 2 か所以上ある場合.Move to:の移動先でも,別の綴りや大文字小文字の違いでも同じ.Move to:は移動元と移動先の両方で判定する.移動先で初めて効くマーカーがあれば,それ自体を新しい抑制として確認する..pyから.goのような単なる移動は通る.MARKER = "ast-grep-ignore"のような文字列なら数えない).agents/hooks.json)content suppressionを加えた.tests/test_ast_grep_rules.py):severity: errorでnoteの無い規則があると失敗する.ユーザーの決定
//nolintも対象にした.文章と規則の対応表
戻し方
static rule のブロックだけを止める環境変数のスイッチは無い(
AGENT_MODEL_RULESは model rule 用で,static rule には効かない).戻すにはこの PR を revert する(squash merge の 1 コミット).急ぐ場合は,問題の規則のseverityをwarningに下げれば,その規則だけ従来の非ブロックの通知に戻る.ただし ADR の「有効か削除か」に反するので,一時的な措置に限る.検証
REQUIRE_AST_GREP=1 REQUIRE_JEV_LINT=1 uv run pytest --cov(b13175e9,CI と同じ設定):5357 passed,1 skipped.以前手元でだけ落ちていた model rule のテストも,main の fix(ci): run the jev-lint model-rule tests in CI #218 の後は通る.ruff check,ruff format --check,ty check,ls-lint,ファイル行数(pre-commit):通過.tests/hooks/test_static_rules.py,tests/hooks/test_lint_format.py)tests/hooks/test_static_rules_trust.py)tests/hooks/test_comment_nodes.py)sgconfig.ymlを読まない.<!--はコメントとする.エンコードできないテキストは不明として扱う.tests/hooks/test_guard_suppression.py,tests/hooks/test_guard_suppression_scope.py)"//nolint",ast-grep が無いときのテンプレート文字列.tests/hooks/test_guard_suppression_target.py)://nolint,noqa,type: ignore,eslint,allow/expect,shellcheck で規則を減らす・変える・加える変更は確認し,移動,削除,横のコードの編集は通る.tests/hooks/test_guard_suppression_budget.py):ハングする ast-grep でも,移動を含むパッチの判定が期限内に終わり,確認する.期限切れの結果は次の判定に持ち越さない.マーカーが多いファイルも 5 秒以内に判定する.import から時間が経っても,判定の外の走査は期限切れにならない(tests/hooks/test_comment_nodes.py).tests/hooks/test_guard_suppression_unparsed.py):YAML のインデント変更と heredoc 終端の挿入は確認し,heredoc の無いスクリプトの無関係な編集は通る.cwdにある相対パスのファイルを読む.***で始まる文脈行で区切りが終わらない,配置できないハンクの断片で文字列に見えるマーカー,文脈行がコメントに変わる場合,Add File,空行,*** End of File,解釈できない行,複数の一致,同じファイルへの重複(別の綴り,大文字小文字,移動先).--!>の変更は確認する.tests/hooks/test_guard_suppression_patch.pyに分けた(ファイル行数の上限のため).tests/test_provider_adapters.py):5 つのアダプタすべてで,新しい抑制がブロックされる.tests/test_ast_grep_rules.py):note の無い error 規則を検出する.main の error 規則 28 件すべてに適用している.レビュー対応
//nolintなどのコメントの指示の判定.--!>),ファイル単位の抑制のコメント判定,移動先で効くマーカーの判定に使う内容,断片の数え方.//nolint:errcheck→//nolintなど)と,理由文の修正での誤検知.***で始まる文脈行,payload のcwd,配置できないハンクの断片,ast-grep が無いときのインデントと heredoc.command-query-naming,error-message-names-operation)_adds,_insert_change,_scan_within_budgetは query の名前に改め,走査の副作用は_scanに寄せた._patch_changesは,返す値で命名した query なので当てはまらない.lint_format.pyのTypeErrorの文言は,この PR より前からある.制限
完全な構文解析が要る理論上の抜け道で,この PR では扱わないもの.
.shと.bashに限る.他の言語の heredoc(Ruby,Perl など)は対象の拡張子に無い.フォローアップ
ユーザーの判断事項
sgconfig.ymlにあるseverity: error規則はブロックする.その規則のmessageとnoteは,エージェントへの指示としてそのまま渡る.マージ後すぐ直す指摘
この PR では直さず,マージ直後のフォローアップ PR で直す(#216 と同じ扱い).
reason = "..."の項目自体の追加・削除まで比較から外れる.🤖 Generated with Claude Code