Skip to content

feat(lint): migrate bash-style and github-actions-style rules to checks - #194

Merged
furedea merged 28 commits into
mainfrom
feat/migrate-bash-and-actions-style-rules
Nov 15, 2026
Merged

furedea merged 28 commits into
mainfrom
feat/migrate-bash-and-actions-style-rules

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

Refs #74(段階 2C: bash-style / github-actions-style),Refs #196

計画: #74 (comment)

概要

bash-style と github-actions-style(SKILL.md と references)の規則を棚卸しし,判定できる最も安い道具へ移した(ADR-0021).

  • ast-grep 規則 6 件(Bash 3 件,GitHub Actions の YAML 3 件)を追加し,例のテストを付けた.すべて severity: error(ブロック).ユーザーの判断(監査の結果)で bash_usage_function は削除した.レビューが収束しなかった bash_strict_mode_header,gha_workflow_default_shell,gha_workflow_concurrency は,ast-grep では構文だけから判定できない(実行順,job と workflow の対応,trigger の多様な書き方)ため,ブロック規則から jev-lint のモデル規則(助言,severity: warning,しきい値 0.5,当てはめは後回し)に降格した.zizmor の concurrency-limits は pedantic persona でのみ同様の検査をするが,それでも降格した.
  • ブロックする ast-grep 規則 9 件すべてに message(なぜ誤りか)と note(そのまま適用できる直し方,1 行の前後例)を付けた.元の note(対象範囲の説明)は YAML のコメントに移した.
  • jev-lint 規則 7 件(Bash 5 件,YAML 2 件)を model-rules/<language>/<id>/rule.yml に追加した.jev-lint は .sh と,ast-grep が解析できる YAML を扱える(jev-lint rules で 19 規則・エラー 0 を確認).fixtures・eval・baseline は未追加(ユーザー指示で後回し).文章は ADR-0021 に従い残した.
  • 既存 linter(shellcheck,shfmt,ls-lint,zizmor)が覆う文章は削除し,規則 ID を表に書いた.
  • 規則で完全に置き換わる文章は同じ PR で削除した.一部だけ覆う文章は残した.

規則の置き場所は agents/hooks/lint/rules/{bash,yaml}/,テストは agents/hooks/lint/rule-tests/.YAML の規則は files: で **/.github/workflows/**(pin コメントのみ **/action.yml / **/action.yaml も)に絞った.hook は絶対パスで ast-grep を呼ぶため,先頭に **/ が要る(レビュー指摘..github/workflows/** だと絶対パスに一致せず規則が動かなかった).sgconfig.yml と hook のコードは変更していない.

共有ファイルの変更(1 件)と追加したテスト

新規 tests/test_ast_grep_workflow_scope.py: 絶対パスで渡した workflow に 5 つの workflow 規則が出ること,.github/workflows の外の YAML には出ないことを確かめる.

tests/hooks/test_lint_format_cli.py: 実際の shfmt を通す 2 つの sh 例が #!/bin/bash と set -eo pipefail で,新しい Bash 規則(bash_shebang_env_bash ほか)の通知を出し「通知なし」の期待に反した.例を規約どおり(#!/usr/bin/env bash,set -euo pipefail)に直した.

文章と規則の対応表

「実装」の ast-grep は agents/hooks/lint/rules/…,例のテストは agents/hooks/lint/rule-tests/… の相対パス.jev-lint は agents/hooks/lint/model-rules/…/rule.yml(しきい値 0.5,fixtures なし).

bash-style / SKILL.md

規則 ID 元の場所 元の規則(原文) 判定 実装 例のテスト 元の文章
bash_shebang_env_bash agents/skills/bash-style/SKILL.md File Header "#!/usr/bin/env bash — resolve Bash from PATH and run with it explicitly, not with sh" 静的(ast-grep,error) rules/bash/bash_shebang_env_bash.yml 良 4 / 悪 2 削除(sh / bash を指す shebang だけを見る.ast-grep が Bash として読む bats と zsh は除く)
bash_strict_mode_header 同 File Header "set -euCo pipefail"(-e -u -C -o pipefail の説明を含む) モデル(jev-lint,助言) model-rules/bash/strict-mode-header/rule.yml fixtures は後回し 降格(ast-grep の規則とテストは削除.prose は -e -u -o pipefail の見出しの説明として残した)
working-directory-by-responsibility 同 File Header "Choose the working directory by responsibility. Hooks that operate on a project must use the target project's working directory…" 動的(jev-lint,0.5) model-rules/bash/working-directory-by-responsibility/rule.yml なし(後回し) 残す(ADR-0021: 昇格まで.規則は cd / pushd を選ぶため,自分のディレクトリへ移る場合だけを判定する.cd なしで相対パスの同梱ファイルを開く場合は選ぶ対象が無く,文章のまま)
tracing-not-left-on-for-secrets 同 File Header "Enable tracing only when useful for debugging; keep it disabled by default for scripts handling secrets or user input" 動的(jev-lint,0.5) model-rules/bash/tracing-not-left-on-for-secrets/rule.yml なし 残す(書き換え: 既定でオフ,秘密とユーザー入力を扱うスクリプトでは付けない,スクリプトを編集せず bash -x ./script.sh で有効にする.よく調べるスクリプトには任意の if [[ "${TRACE-0}" == "1" ]]; then set -o xtrace; fi.この行を要求する規則は無い)
tracing-not-left-on-for-secrets 同 File Header "suppress it around noisy or sensitive sections. Restore it only when subsequent commands are safe to trace" 動的(jev-lint,0.5) 上と同じ規則 なし 残す
(なし)(bash_usage_function は削除) 同 usage Function "Every script must define a usage function that prints documentation" 文章のまま(ユーザーの判断で規則を削除) — — 残す(引数を取るスクリプトに限る形に書き換えた.引数の有無は構文から判定できず,数行の hook に要求すると手間が大きい)
(なし) 同 usage Function "Use a heredoc inside the function body" 文章のまま — — 残す(形は構文で判別できるが,価値に対して誤検出の調整が大きい)
usage-help-and-error-exits 同 usage Function "For requested help, call usage and exit 0. For missing or invalid arguments, call usage >&2 and exit 1" 動的(jev-lint,0.5) model-rules/bash/usage-help-and-error-exits/rule.yml なし 残す
script-constants-readonly 同 Constants "Declare constants with readonly" 動的(jev-lint,0.5) model-rules/bash/script-constants-readonly/rule.yml なし 残す
bash_readonly_constant_name 同 Constants / Naming "Names use SCREAMING_SNAKE_CASE" 静的(ast-grep,error) rules/bash/bash_readonly_constant_name.yml 良 5 / 悪 3 削除(readonly -f(関数名)は除外し,その valid 例を追加.規則は readonly で宣言した名前だけを見る.Naming 表は変数の snake_case の 1 文にした)
shellcheck SC2086 / SC2046 同 Constants "Always quote the right-hand side — values may contain spaces or special characters" 既存 linter(shellcheck.hook が全リポジトリで shellcheck -x を実行,lefthook.yml でも有効) — — 削除
shellcheck SC2086 同 Variables "Quote all parameter expansions and string values to guard against word splitting and glob expansion" 既存 linter(shellcheck SC2086) — — 削除
(なし) 同 Variables "Use default values for variables that may be empty or undefined" 文章のまま — — 残す(どの変数が空になりうるかは設計の判断で,yes/no の基準にできない)
function-variables-local-near-use 同 Variables "Define variables just before first use (minimize lifetime)" 動的(jev-lint,0.5) model-rules/bash/function-variables-local-near-use/rule.yml なし 残す
(なし) 同 Naming "Variables: snake_case" 文章のまま — — 残す(定数 NAME=…; readonly NAME の 2 段書きと区別できず,構文から変数と定数を分けられない)
bash_function_name_snake_case 同 Naming "Functions: snake_case" 静的(ast-grep) rules/bash/bash_function_name_snake_case.yml 良 3 / 悪 4 削除(表の行)
bash_function_name_snake_case 同 Naming "Do not start names with a digit" 静的(ast-grep)+ Bash の構文エラー 同上(関数名).変数名は Bash が受け付けない 良 3 / 悪 4(1st_step) 削除
bash_local_underscore_prefix(#117) 同 Naming "Local variables: _snake_case (leading underscore)" 静的(ast-grep,既存) rules/bash/bash_local_underscore_prefix.yml 既存 表の行を削除.接頭辞の後の snake_case は規則が覆わず,Variables 行に残る
bash_local_underscore_prefix(#117) 同 Local Variables "Declare function-local variables with local and prefix with _" 静的(既存)+動的 上と function-variables-local-near-use 既存 「_ で始める」だけ削除.local で宣言する指示は残す
function-variables-local-near-use 同 Local Variables "Declare function-local variables with local" 動的(jev-lint,0.5) 上 なし 残す
shfmt(.editorconfig) 同 Formatting "Indent with 2 spaces … shfmt reads it automatically. Run shfmt -d <file>" 文章のまま(#196 の方針) — — 残す(template-* に shfmt の設定も .editorconfig も無い.hook の shfmt -w は .editorconfig が無いと tab にする)
shellcheck 同 Formatting "Common quoting errors are caught by shellcheck" 既存 linter(hook が shellcheck -x を全リポジトリで実行) — — 削除(案内の文.規則ではない)
(なし) 同 Task-Specific References 参照先の案内 文章のまま(案内) — — 残す

bash-style / references

規則 ID 元の場所 元の規則(原文) 判定 実装 例のテスト 元の文章
ls-lint(template-minimal の .* の正規表現) references/bats_testing.md Directory Layout "Test files: .bats extension, snake_case naming" 既存 linter(template-minimal の .ls-lint.yml.ハイフンを許さない) — — snake_case だけ削除.拡張子の指示は ls-lint が覆わないため残す
(なし) 同 Directory Layout test-helper/ の名前,カテゴリごとに置く,.bash 拡張子,load test-helper/setup 文章のまま — — 残す(プロジェクト慣習.名前の形は ls-lint の .dir が見るが,この名前に固定する規則は無い)
(なし) 同 File Structure #!/usr/bin/env bats,説明コメント 1 行,setup() に配線を置き assertion を置かない,REPO_ROOT を inline で求める 文章のまま — — 残す(ast-grep の Bash 文法は @test "…" { } を構文エラーとして読み,.bats は sgconfig.yml の言語対応にも無い.shellcheck も bats を扱わず,jev-lint の対象拡張子にも無い)
(なし) 同 Setup / Teardown Lifecycle 最も狭いスコープを使う,setup_file の変数を export する 文章のまま — — 残す(同上.判断を含む)
(なし) 同 Test Naming / Section Separators "descriptive lowercase sentence",コメントの区切り 文章のまま — — 残す(同上)
(なし) 同 Assertions / Loop-Based Assertions 素の bats の組み込みを使う,run の後で $status を見る,run を省くのは副作用だけを見る時,ループでは失敗した要素を出す 文章のまま — — 残す(同上)
(なし) 同 Helper Functions / Temporary Directories 共有 fixture は test-helper/setup.bash,JSON は jq,gh などの stub は $BATS_TEST_TMPDIR/bin,mktemp より BATS_*_TMPDIR 文章のまま — — 残す(同上)
(なし) 同 Making Scripts Testable BASH_SOURCE == $0 で main を守る 文章のまま — — 残す(テスト容易性の設計判断.script_template.md は守らない形で書かれており,構文だけで必須にできない)
(なし) 同 Running Tests コマンド例 文章のまま(案内) — — 残す
(なし) 同 Test Organization Rules 1 スクリプト 1 .bats,正常系を先に,1 @test 1 振る舞い,本体を短く 文章のまま — — 残す(判断を含み,.bats を解析できる道具が無い)
(なし) references/script_template.md スクリプトの雛形 文章のまま(雛形) — — 残す

github-actions-style / SKILL.md

規則 ID 元の場所 元の規則(原文) 判定 実装 例のテスト 元の文章
gha_workflow_permissions_deny_all agents/skills/github-actions-style/SKILL.md 1. Permissions "Declare permissions: {} at the workflow level (deny-all)" 静的(ast-grep)+ zizmor excessive-permissions rules/yaml/gha_workflow_permissions_deny_all.yml 良 1 / 悪 3 該当の文だけ削除(例の YAML は残す)
job-permissions-least-privilege 同 1. Permissions "grant only what each job actually requires" 動的(jev-lint,0.5)+ zizmor excessive-permissions(広すぎる書き込み権限) model-rules/yaml/job-permissions-least-privilege/rule.yml なし 残す
(なし) 同 1. Permissions "Common permission keys: …" 文章のまま(参考の一覧) — — 残す
zizmor unpinned-uses 同 2. Version Pinning "Pin every action to a full commit SHA" 既存 linter(zizmor.hook が .github/workflows の編集後に全リポジトリで zizmor --offline を実行.tag 参照で error[unpinned-uses] を確認) — — 削除(節ごと)
gha_pinned_uses_version_comment 同 2. Version Pinning "record the version in a comment for readability and update tooling" 静的(ast-grep) rules/yaml/gha_pinned_uses_version_comment.yml 良 3 / 悪 5 削除(上と同じ節)
zizmor template-injection 同 3. Script Injection Prevention "Always pass them through env: instead, and quote the variable in the script" 既存 linter(zizmor.例の run: echo "${{ github.event.pull_request.title }}" で error[template-injection] を確認) — — 削除(節ごと.危険な入力の一覧も含む)
gha_job_timeout_minutes 同 4. timeout-minutes "Set an explicit timeout appropriate for the job" 静的(ast-grep) rules/yaml/gha_job_timeout_minutes.yml 良 5 / 悪 4 「設定する」の文だけ削除
(なし) 同 4. timeout-minutes "typically 5–15 minutes for CI" 文章のまま — — 残す(値の選択は判断.規則は有無だけを見る)
gha_workflow_default_shell 同 5. Shell Settings "Set it at the defaults.run level" モデル(jev-lint,助言) model-rules/yaml/workflow-default-shell/rule.yml fixtures は後回し 降格(ast-grep の規則とテストは削除.prose は defaults.run.shell: bash の説明として残した)
(なし) 同 5. Shell Settings "For debugging, add set -x at the top of a run: block" 文章のまま(デバッグの手引き) — — 残す
gha_workflow_concurrency 同 6. Concurrency "Use concurrency to cancel stale runs automatically" モデル(jev-lint,助言) model-rules/yaml/workflow-concurrency/rule.yml fixtures は後回し 降格(ast-grep の規則とテストは削除.prose は concurrency の説明として残した)
(なし) 同 6. Concurrency "use false for deploy workflows that must run in order" 文章のまま — — 残す(デプロイ用かどうかは構文から判別できない)
cache-key-and-trust 同 7. Cache Design "Include every compatibility boundary in the primary key… Always keep a correct cache-miss fallback" 動的(jev-lint,0.5) model-rules/yaml/cache-key-and-trust/rule.yml なし 残す
cache-key-and-trust 同 7. Cache Design "Do not cache broad paths that may contain credentials" 動的(jev-lint,0.5) 上と同じ規則 なし 残す
(なし) 同 7. Cache Design "Measure representative cold and warm runs…",cache scope の説明,外部 backend で untrusted workflow に書かせない 文章のまま — — 残す(計測の手順と文脈で,ワークフローの構文に現れない.zizmor cache-poisoning は一部だけ覆う)
(なし) 同 8. Workflow File Names "Name workflow files in kebab-case with the .yml extension" 文章のまま — — 残す(template-minimal の .ls-lint.yml に .github/workflows の kebab-case 規則は無い.agent-config 自身の .ls-lint.yml にだけある.節番号は 6 に変わった)

波 2: linter で有効化する規則

なし.この PR で消した文章は,すべて既に有効な linter(shellcheck と shfmt は agent-config の lefthook.yml,zizmor と actionlint は furedea/reusable-workflows の gha-lint,ls-lint は .ls-lint.yml)が覆う.

注: Bash 向けのテンプレートは無く,template-python などの lefthook.yml に shellcheck と shfmt は無い.Bash を書く他のリポジトリでは,agent-config と同じ lefthook.yml の設定が要る(このリポジトリの対象外).

現在の hit(読み取りのみ.修正はこの PR に含めない)

ast-grep scan --config agents/hooks/lint/sgconfig.yml --no-ignore hidden .(.github は隠しディレクトリのため).agent-harness の bash_usage_function は隠しディレクトリ内の script を含めて 7 件.

規則 agent-config agent-harness dotfiles
bash_shebang_env_bash 1(tests/hooks/fake_herdr.sh,意図した POSIX sh の stub) 0 3
bash_strict_mode_header(新しい緩い定義) 1(同じ fake_herdr.sh.sh は pipefail を持たない) 0 0
bash_local_underscore_prefix(既存) 0 0 6
bash_function_name_snake_case 0 0 0
bash_readonly_constant_name 0 0 0
gha_workflow_permissions_deny_all / gha_job_timeout_minutes / gha_workflow_default_shell / gha_workflow_concurrency / gha_pinned_uses_version_comment 0 0 0

新しい strict-mode 規則では,dotfiles の違反は 0 件(-C を外し,表記を問わなくした結果.旧定義では 21 件).shebang の規則も sh / bash だけを見る形になり,24 件から 3 件に減った.dotfiles は修正していない.

検証

  • nix develop --command ast-grep test --config agents/hooks/lint/sgconfig.yml --skip-snapshot-tests: 20 規則すべて通過.
  • jev-lint rules --no-config -R agents/hooks/lint/model-rules: 19 規則・エラー 0.jev-lint check --dry-run --show-subjects で Bash の 5 規則と YAML の job-permissions-least-privilege が意図した対象を選ぶことを確認した(usage-help-and-error-exits と cache-key-and-trust は試料に該当が無く未確認).
  • REQUIRE_AST_GREP=1 nix develop --command uv run pytest: 4877 件通過,3 件失敗.失敗は tests/test_workflow_skill_layout.py の 3 件で,この worktree にだけある .claude/.cc-writes(Claude Code のサンドボックスが作る未追跡ディレクトリ)を skill ディレクトリと読むため.CI の checkout には無く,この PR の変更とは無関係.
  • lefthook の pre-commit(shfmt,shellcheck,ls-lint,ruff,ty,file-length)通過.

残りの作業

  • fix(lint): address review findings deferred from the #74 migration PRs #196 gha_workflow_concurrency が単一引用符の 'on': キーを認識しない: 修正(a3ac148,invalid 例を追加).

  • 方針(template-* の linter が覆う文章は削除): template-minimal の ls-lint が覆う bats の snake_case は削除.template に設定の無い shfmt のインデントと workflow ファイル名の kebab-case は残す.shellcheck と zizmor / actionlint(template-minimal の gha-lint)で消した文章はそのまま.

  • レビュー上限(fix(lint): address review findings deferred from the #74 migration PRs #196 の修正後の再レビュー 3 回)で見送った指摘(フォローアップ Issue で扱う):

    • usage-help-and-error-exits: if (( $# == 0 )) のような引数不足の分岐が subject にならない.
    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_default_shell: 引用符付きの "run": キーを run step と認識しない.
    • cache-key-and-trust: flow mapping 形式の step(- {uses: actions/cache@v4, …})が subject にならない.
    • gha_workflow_permissions_deny_all: 引用符付きの "jobs": キーを workflow と認識しない.
    • zizmor の既定が actions/* を tag 固定で許すという指摘(SKILL の Version Pinning 削除): 再現しない.zizmor 1.31.0 は設定なしで actions/checkout@v4 に unpinned-uses(blanket policy で hash 固定を要求)を出す.CI の gha-lint は 1.32.0.確認の上で見送り,スレッドは解決済み.
  • レビュー上限(template 方針の変更後の再レビュー 3 回)で見送った指摘:

    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_concurrency: block sequence 形式の on:(- push)の trigger を認識しない.
    • gha_pinned_uses_version_comment: action.yml 内の tag 参照は,この規則も zizmor(workflow のみ)も検出しない.
    • SKILL の Version Pinning 削除と zizmor の既定方針(再現しない.上に記載).
  • レビュー上限(最終決定の反映後の再レビュー 3 回)で見送った指摘:

    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_default_shell: 複数 job で 1 つの job だけが defaults.run.shell を持つと,別の job の run: も通ってしまう(job ごとの対応付けが要る).
    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_concurrency: 引用符付きの "cancel-in-progress" キーを認識しない.
    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_concurrency: block sequence 形式の on:(- push)を認識しない(上と同じ.再指摘).
    • (obsolete: 規則を jev-lint に降格したため不要)bash_strict_mode_header: 後続の無関係な set(set +u の後の set -x)があると無効化を見逃す.
    • (obsolete: 規則を jev-lint に降格したため不要)bash_strict_mode_header: 無効化の後に別の set があるだけで免除してしまう(実際に再有効化する場合だけ免除すべき).
    • usage-help-and-error-exits(jev-lint): getopts h opt の bare h ラベルが subject にならない.
    • gha_workflow_permissions_deny_all: ルート全体が flow mapping の workflow を認識しない.
    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_default_shell: strategy.matrix.defaults など無関係な shell を defaults.run.shell と取り違える.
    • job-permissions-least-privilege(jev-lint): flow 形式の job の permissions が subject にならない.
    • function-variables-local-near-use(jev-lint): : "$((count++))" の代入が subject にならない.
    • (obsolete: 規則を jev-lint に降格したため不要)bash_strict_mode_header: 同じ set コマンド内の再無効化(set -euo pipefail +e)を見逃す.
    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_default_shell: block sequence の要素が flow mapping の run step(- {run: …})を見逃す.
  • レビュー上限(再実行後の再レビュー)で見送った指摘(fix(lint): address review findings deferred from the #74 migration PRs #196 に追記済み):

    • bash_readonly_constant_name: 関数内の readonly を一律に除外している(local -r だけを除外すべき).
    • bash_readonly_constant_name: declare -r NAME=… を選択しない.
    • gha_job_timeout_minutes: jobs 自体が flow mapping の workflow を見逃す.
    • gha_pinned_uses_version_comment: action.yml の tag 参照を検出しない(上と同じ.再指摘).
    • (obsolete: 規則を jev-lint に降格したため不要)gha_workflow_default_shell: shell: env pipefail=1 bash -e {0} を適合扱いにする(pipefail が環境変数名として現れるだけ).
    • (obsolete: 規則を jev-lint に降格したため不要)bash_strict_mode_header: set +e の後ろの set が実際に再有効化するかを見ていない(上の再指摘).gha_workflow_concurrency の block sequence 形式の on: も再指摘.
    • gha_job_timeout_minutes / gha_workflow_default_shell: 引用符付きの "jobs": キーを認識しない.
    • cache-key-and-trust(jev-lint): flow 形式の cache step(steps: [{uses: …}])が subject にならない.
  • 誤検出の修正: gha_job_timeout_minutes の flow mapping の分岐が jobs 配下の job に限定されず,step の with: {runs-on: …} を報告していた.job の値である flow mapping だけを対象にした(valid 例 2 件を先に追加して失敗を確認).

  • bash_readonly_constant_name が readonly OUTPUT="$input" の右辺を定数名として検査するという指摘: 現行の規則では再現しなかった(右辺の変数は simple_expansion 配下で,declaration_command の直下ではない).再発防止のため,この形の valid 例を 2 件追加した.

  • 誤検出の修正(ユーザーの常時許可): bash_shebang_env_bash が先頭以外のコメントの #! を報告していた.ファイルの最初の node だけを shebang とするように直し,先に valid 例(後ろのコメントの #!/bin/bash,先頭がコメントの場合)を追加して失敗を確かめてから修正した.

  • 同じ誤検出の修正: bash_strict_mode_header も先頭以外のコメントの #! を shebang と読んでいた.最初の node だけに限定した(valid 例を先に追加して失敗を確認).

  • 誤検出の修正(続き): gha_workflow_default_shell が flow 形式の defaults: {run: {shell: bash}}(規則自身の note の直し方)を受け付けなかった,gha_workflow_permissions_deny_all が引用符付きの "permissions": {} を受け付けなかった,bash_strict_mode_header が後で再有効化する set +e … set -e を誤検出した.いずれも valid 例を先に追加して直した.gha_workflow_concurrency の note は group を引用符で囲み,YAML として有効にした.

  • main の新しいテスト(tests/test_ast_grep_rules.py の file-scoped 規則の flagged / clean パス)に追従した: main に rebase し(CI の test が落ちた原因),5 つの workflow 規則の flagged(.github/workflows/ci.yml,pin 規則は action.yml も)と clean(config/ci.yml)のパスを追加した..github は隠しディレクトリのため,その走査に --no-ignore hidden を足した.

  • rule_notes.md(全ブロック規則に message と note)は適用済みであることを確認した.

  • fix(lint): address review findings deferred from the #74 migration PRs #196 .bats を Bash として読めるか: 追加しない.調べた結果は下記.

  • jev-lint 規則 7 件の fixtures,eval,しきい値の調整,昇格(その後に文章を削除).

  • .bats の規則(調査済み,下記): sgconfig.yml の languageGlobs で .bats を Bash として読めるか,@test の構文エラーをどう扱うかを調べる必要がある.この PR では共有設定を変えなかった.

ast-grep から外した規則と理由

ブロックする規則は結果が安定していなければならない.次の規則は review のたびに新しい指摘が出続け(1 規則あたり 11〜15 件のスレッド),収束しなかった.そのためユーザーの判断で,既存のツールに任せるか jev-lint に降格した.この基準は ADR-0021 に記録する.

規則 行き先 review の指摘数 不安定の型 例
gha_workflow_default_shell jev-lint(model-rules/yaml/workflow-default-shell,助言) 15 2, 3, 4 shell: env pipefail=1 bash -e {0} を適合扱いにした(pipefail という文字列だけを正規表現で見ていた).別 job の defaults.run.shell で複数 job の run: が通った.
gha_workflow_concurrency jev-lint(model-rules/yaml/workflow-concurrency,助言.zizmor の concurrency-limits は pedantic persona のみ) 12 3, 4 on: が - push の block sequence や 'on': の引用符付きキーだと認識しない.
bash_strict_mode_header jev-lint(model-rules/bash/strict-mode-header,助言) 11 2, 3, 4 set +e の後に set -x があるだけで免除してしまう.set -euo pipefail +e の同一コマンド内の再無効化を見逃す.-Eeuo や -o errexit など同じ意味の書き方が多い.
bash_usage_function 削除(prose の usage の節は残し,引数を取るスクリプトに限定) 0 —(ユーザーの判断.引数を取るかどうかは文脈で決まる) —

残した 6 件の ast-grep 規則(bash_shebang_env_bash,bash_function_name_snake_case,bash_readonly_constant_name,gha_workflow_permissions_deny_all,gha_job_timeout_minutes,gha_pinned_uses_version_comment)の指摘数は 3〜7 件で,誤検出は修正し,見逃しは #196 に送った.

.bats を ast-grep で Bash として読めるか(#196)

languageGlobs は不要で,追加しなかった.ast-grep 0.42.1 は .bats を既に Bash として読む(tests/codex/execpolicy.bats の shebang コメントに Bash 規則が一致した.上の bats shebang の例外はこのため).ただし構文は正しく読めない.@test "name" { は関数ではなく 1 つの command(@test が名前,"name" と { が引数)になり,本体は兄弟の文として並ぶ.run コマンドを kind: command で選んでも 0 件だった(実際には多数ある).構文エラーとして報告はされないため,誤検出の代わりに見逃しが静かに起きる.よって @test の中を見る規則は書けず,bats の規則は文章のままにした.

review の扱い(最終方針)

  • ブロックする ast-grep 規則の誤検出は,テストを先に書いて修正する.
  • jev-lint モデル規則の指摘(マッチャー,criteria,しきい値)は,ユーザーの判断で検証を後回しにし,#196 の jev-lint verification notes に記録して解決済みにする.
  • ルール以外のコード(hooks,docs)の実害は修正する.

🤖 Generated with Claude Code

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T14:51:31.830579Z 478f4c6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Review summary

Findings: 0 × P0, 0 × P1, 1 × P2, 0 × P3. None of them block the merge.

  • P2 gha_workflow_default_shell: the rule flags workflows that only call reusable workflows (for example this repo's release-please.yml). Its own note says those are excluded. See the inline comment for a fix and a missing test case.

Checked statically, no finding:

  • bash_readonly_constant_name: the default inside stopBy is neighbor, so $var expansions inside the value don't match.
  • The other Bash rules: shebang, strict mode, usage, snake_case.
  • The YAML rules: timeout, concurrency (pull_request_target is excluded by \b), permissions, and the pinned-uses comment.
  • The fixture fix in test_lint_format_cli.py.

I couldn't run ast-grep here because the sandbox blocked it, so I didn't execute the rule tests.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6fd40df8e9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

Blocking: 1 (P1)

  • P1: The workflow-only YAML rules (gha_workflow_permissions_deny_all, gha_job_timeout_minutes, gha_workflow_concurrency, gha_workflow_default_shell, and the workflow pattern in gha_pinned_uses_version_comment) limit themselves with files: .github/workflows/**. The lint hook passes absolute paths to ast-grep scan --config <shared sgconfig>, and the shared config sits in agents/hooks/lint/. So the glob probably never matches, and these rules never fire. ast-grep test doesn't exercise the path filter, so the passing rule-tests don't show this. Suggested fix: **/.github/workflows/**, plus one scan test with an absolute workflow path. Details are in the inline comment.

I couldn't run ast-grep in this environment, so the glob behaviour comes from reading the code rather than from a run.

Checked, no findings:

  • Bash rules (shebang, strict-mode header, usage, readonly constant names, function names): the rule logic and examples look correct. The hook only scans .sh, so .bats files with #!/usr/bin/env bats aren't affected.
  • The repo's own ci.yml follows the new GHA rules, including defaults.run.shell matching bash|pipefail.
  • The test_lint_format_cli.py example update is consistent with the new Bash rules.
  • The SKILL.md deletions match the rules or existing linters (shellcheck, shfmt, zizmor) listed in the PR table.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 052d03d78e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

Blocking findings (P0/P1): 0

  • P2 agents/skills/github-actions-style/SKILL.md: the PR deletes the SHA-pinning text and relies on zizmor unpinned-uses instead. But zizmor's default policy accepts tag pins (ref-pin) for actions/*, github/* and dependabot/*, and this repo has no zizmor config that changes that. So actions/checkout@v4 is no longer flagged by the skill text, by zizmor, or by the new ast-grep rule. Details are in the inline comment.

I read through the new ast-grep rules (Bash: shebang, strict-mode header, usage function, function and constant naming; workflow YAML: permissions, default shell, concurrency, timeout, version comment on pinned actions), their rule tests, the workflow-scope pytest and the updated test_lint_format_cli.py examples. I found no correctness problems. Their scoping matches what the notes describe: shebang-only files, .github/workflows/**, skipping reusable-workflow jobs, and pull_request_target not matching the concurrency trigger.

I could not run ast-grep in this environment, so I checked the rule tests by reading them only. I did not run them. Per the PR description, the jev-lint model rules have no fixtures or evals yet.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e6178d2f3a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary (read-only)

  • P2: The new Bash ast-grep rules have no file scoping. ast-grep's default Bash language includes the .bats and .zsh extensions, so the lint hook would warn on bats test files. The warnings say to swap the #!/usr/bin/env bats shebang, add set -euCo pipefail, and add a usage function, which would break those files. Details in the inline comment.

Checked with no issues: the YAML workflow rules (AST nesting for jobs, defaults.run.shell, concurrency, permissions: {}, pinned-SHA comments) and the files: scoping with the **/ prefix for absolute paths. Also checked the readonly constant-name rule, which only looks at direct children so expansions in the value don't trigger it, and the test fixture updates. I couldn't run ast-grep locally, so this review is static.

Blocking findings: 0

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 26d286cbd8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No findings: nothing at P0/P1, and no P2/P3 issue strong enough to post.

What I checked:

  • ast-grep rules (5 Bash, 5 YAML). I read each rule's matcher logic: inside/has depths, follows in the strict-mode rule, and the precedes trailing-comment check in the pin-comment rule. I compared them with their valid/invalid examples. The shebang regex \b(ba)?sh\b correctly leaves zsh/bats alone, and the readonly rule's inside (neighbor) avoids matching $var expansions on the right-hand side.
  • files: globs. **/.github/workflows/** matches both absolute paths (how static_rule_scan passes them) and repo-relative paths, and tests/test_ast_grep_workflow_scope.py covers both the in-scope and out-of-scope cases.
  • Deleted prose and the tools said to cover it. The lint hook's workflow_plan runs actionlint and offline zizmor, so removing the pinning and injection sections still leaves them enforced (unpinned-uses, template-injection) whenever a workflow is edited. .ls-lint.yml enforces kebab-case workflow names. bash_local_underscore_prefix (feat(lint): add the first ten ast-grep rules and drop the prose they replace #117) covers the removed _ local-variable rule.
  • test_lint_format_cli.py. The updated sh examples now meet all of the new Bash rules, so the expectation of no diagnostics is still correct.

Limitation: I couldn't run ast-grep test in this environment, so this review is static analysis only. The rule-tests results in the PR description are the runtime evidence.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9676cb6325

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

Blocking findings: 0 (P0: 0, P1: 0, P2: 0, P3: 1)

  • P3 gha_workflow_default_shell: the shell-value regex bash|pipefail also matches custom templates like bash -e {0}, which run without pipefail (inline comment).

Reviewed: the 10 new ast-grep rules and their rule tests, the 7 jev-lint model rules, the SKILL.md deletions, tests/test_ast_grep_workflow_scope.py and the updated test_lint_format_cli.py cases. The shebang regex correctly leaves bats/zsh/dash/ksh alone. The strict-mode ordering logic, the readonly scoping outside functions and the **/.github/workflows/** globs for absolute paths all look correct. This repo's own workflows and scripts/bootstrap_server.sh already follow the new rules.

Note: this review was static. ast-grep isn't installed in the review environment, so I didn't run the rule tests myself and relied on the verification reported in the PR description.

🤖 Generated with Claude Code

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3ac148162

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary (read-only)

I checked the 10 new ast-grep rules (Bash and GitHub Actions YAML), their example tests, the 7 jev-lint model rules, the edits to bash-style and github-actions-style SKILL.md, the updated integration examples in tests/hooks/test_lint_format_cli.py, and the new tests/test_ast_grep_workflow_scope.py.

No P0–P3 findings.

  • Rule logic: I traced each rule against the tree-sitter structure it matches:

    • The jobs → job nesting in gha_job_timeout_minutes.
    • The direct-sibling follows check in bash_strict_mode_header.
    • The direct-parent inside in bash_readonly_constant_name, so $var inside a value is not matched.
    • The run:-in-step check in gha_workflow_default_shell.
    • The files: scoping on the hook's absolute paths.

    I found no wrong matches or missed matches worth blocking on.

  • Tests: each new static rule has valid and invalid examples. The workflow-scope test covers the absolute-path case that static_rule_scan relies on.

  • Limitation: ast-grep and zizmor are not installed in the review environment, so I did not run the rule tests. I also could not reproduce the PR's claim that zizmor's unpinned-uses rejects tag references such as actions/checkout@v4 under the default config. The deletion of the Version Pinning section depends on that claim.

Blocking findings: 0

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dfbd83a7ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea

furedea commented Nov 14, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings (P0: 0, P1: 0). No inline comments posted.

Reviewed: the 10 new ast-grep rules (5 Bash, 5 GitHub Actions YAML) and their rule tests, the 7 jev-lint model rules, the SKILL.md prose removals, the test_lint_format_cli.py example fixes, and the new tests/test_ast_grep_workflow_scope.py.

  • YAML rule scope: the rules are limited to **/.github/workflows/** (plus **/action.y{a,}ml for the pin-comment rule). The new test checks both cases with an absolute path, the way the hook passes it: rules fire inside the workflow directory and stay silent outside it.
  • Rule logic: I traced each rule's tree-sitter structure by hand. Nothing looked wrong: the jobs → job nesting for timeout-minutes, the on: trigger detection (pull_request_target correctly does not match \bpull_request\b), the defaults.run.shell check limited to workflows with run: steps, set -euCo pipefail allowing only comments and function definitions before it, and the shebang regex skipping zsh, dash and bats.
  • Impact: static_rule_scan reports these as non-blocking warnings, and tests/hooks/test_static_rules.py already covers that. So the existing hits listed in the PR body cause noise, not failures.
  • Removed prose: each deletion is backed by an ast-grep rule with tests, or by shellcheck or zizmor, which the hook runs. The text whose linters (ls-lint, shfmt indent) only run under per-project config was restored.
  • Limitation: I couldn't run ast-grep test in this environment, so the rule-test results come from the PR's own verification log, not from me.

furedea and others added 10 commits November 15, 2026 23:37
…es to jev-lint

These blocking ast-grep rules drew 11-15 review threads each and never
converged: they need execution order, job-to-workflow mapping, or regex
parsing of many equivalent spellings. Hand them to jev-lint as advisory
model rules; the style prose stays until they are promoted.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
furedea
furedea previously approved these changes Nov 15, 2026
@furedea-agent
furedea-agent Bot force-pushed the feat/migrate-bash-and-actions-style-rules branch from 3d6a346 to 478f4c6 Compare November 15, 2026 14:46
@furedea

furedea commented Nov 15, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

I found no blocking issues and posted no inline comments.

What I checked:

  • New blocking ast-grep rules (bash_shebang_env_bash, bash_readonly_constant_name, gha_job_timeout_minutes, gha_pinned_uses_version_comment, gha_workflow_permissions_deny_all): I read each rule's logic. These rules have no false positives in the repo's own files:
    • Both .github/workflows/*.yml files already have permissions: {}, a timeout-minutes on every runs-on job, and a version comment on every SHA-pinned uses:.
    • Every .sh shebang is #!/usr/bin/env bash.
    • Every readonly in scripts/bootstrap_server.sh uses SCREAMING_SNAKE_CASE.
  • The files: scope **/.github/workflows/** works for both absolute paths (tests/test_ast_grep_workflow_scope.py) and repo-relative paths (tests/test_ast_grep_rules.py with --no-ignore hidden).
  • The demoted jev-lint model rules (strict-mode-header, workflow-default-shell, workflow-concurrency) are advisory (severity: warning), so they cannot block.

Known limits that are already listed as deferred in the PR body: action.yml tag refs, flow-mapping jobs, and declare -r. They are not regressions.

ast-grep isn't installed in this review environment, so I didn't run the rule example tests here; CI runs them with REQUIRE_AST_GREP=1.

No P0, P1, P2 or P3 findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 478f4c66a0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@furedea
furedea merged commit 4e473ba into main Nov 15, 2026
25 of 48 checks passed
@furedea
furedea deleted the feat/migrate-bash-and-actions-style-rules branch November 15, 2026 15:00
furedea added a commit that referenced this pull request Nov 15, 2026
Refs #74
Refs #196

## 概要

ADR-0021 に「Which rules ast-grep may block」の節を追加し,blocking な ast-grep
規則に求める基準を記録した.

- blocking な ast-grep 規則は,1
つの構文要素を局所的に,信頼できる形で判定しなければならない.次のどれかが必要な規則は,言語自身の linter / compiler /
test runner(あれば),なければ jev-lint に任せる.
  1. ファイル外の情報(設定,`conftest.py`,他のモジュール)
  2. データの流れや実行の順番(代入,スコープ,クラス階層)
  3. 文法や式を正規表現で解析すること(`cfg(...)`,文字列の中身)
  4. 同じ意味の書き方が多いこと(YAML の引用符・flow / block 形式,import の別名)
- 根拠として,#192〜#195 のマージ済み PR 本文の「ast-grep から外した規則と理由」の表から,指摘 8 件以上の 12
規則を表にした(規則,指摘数,型,行き先).
- `agents/hooks/lint/sgconfig.yml` の先頭に,この節への 1 行の案内をコメントで追加した.
- `tests/test_workflow_skill_layout.py`: 追跡されていない
`agents/skills/.claude/` が skill として読まれ,環境によって失敗する問題を直した.`.` で始まる名前を
`SKILL_NAMES` から除外する(`skill_names()`,先にテストを追加して失敗を確認).

## 補足

- #194 は作成時点で未マージのため,ADR の #194 の 3 行は暫定と明記した(レビュー指摘).
- 依頼文では「外した規則は 11〜34 件」とあったが,PR 本文の表には 1〜8 件の規則もある(#193 の Rust など).表には 8
件以上のものだけを載せ,それ未満は「同じ PR 本文に載っており,同じ型に当てはまる」と ADR に書いた.ブロックのまま残った規則は 3
件以下(#194 の Bash / GitHub Actions は 3〜7 件で,見逃しは #196 に送った)と書いている.
- 指摘数は各 PR 本文の記載値をそのまま使った(再集計していない).

## 検証

- `uv run pytest tests/test_workflow_skill_layout.py`: 61
件成功(新規テストは,実装前に `NameError` で失敗することを確認).
- pre-commit(ruff,ty,shellcheck,commitlint ほか)通過.`dprint fmt` 済み.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
furedea added a commit that referenced this pull request Nov 16, 2026
## 概要

#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 <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
furedea added a commit that referenced this pull request Nov 16, 2026
…ore (#203)

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 で解決したコンフリクト

- 1 回目(#190,#202,#205,#208 の後):ブランチのコミットごとに同じ関数で衝突したため,1 コミットにまとめてから
rebase した(squash merge なので結果は同じ).
- `agents/hooks/lib/static_rule_scan.py`:#202 の「設定ごとの基準ディレクトリから repo
相対パスで走査する」(`scan_root`,`cwd=root`,`--`)と,この PR の `Report`(error と advice
の分離),`note` の表示,信頼判定を両方残した.
- #202 の,git の無いプロジェクトでマニフェストのディレクトリを基準にするフォールバックと,そのテストは削除した.ユーザーの決定
(a) により共有規則は信頼できるリポジトリの中でしか走らないので,このフォールバックには到達しない.
- `tests/test_ast_grep_rules.py`:#190 の「error の規則は note を持つ」テストが,この PR の
`NOTE_PATTERN` を同名で上書きしていた.#190 の規則ごとのテストを残し,この PR の判定(空のブロック note
も検出する)を使うようにした.
    - `checkout_of` フィクスチャを `tests/conftest.py` に移した.
- 最新(#214,#215,#217,#218 の後):#215 で ADR が MADR の front matter
形式になったので,この PR の改訂日を front matter の `amended` に加えた.#214 が ADR-0021
に足した「Which rules ast-grep may block」の節は,この PR の改訂と矛盾しない.
- 2 回目以降(#191〜#195,#198,#199,#212 の後):テキストのコンフリクトは無かった.#194 で YAML
の規則が入ったので,「規則の言語はすべて抑制ガードの対象」というテストに yaml を加えた.YAML の `ast-grep-ignore`
はもともと検査している.

## 概要

ユーザーの決定:static(ast-grep)規則は,linter のエラーと同じくブロックする.advisory
の段階は設けず,規則は「有効(`severity:
error`,ブロックする)」か「削除」のどちらかとする.まれな正当な例外は,理由を書いた抑制コメントで扱う.抑制コメントはエージェントが勝手に追加してはならず,ユーザーが承認する.

- **ADR-0021 の改訂**(`docs/adr/0021_*.md`)
- static rule は編集時にブロックする.「advisory で始めて昇格する」経路は削除した.jev-lint の model
rule は変えていない.
    - 共有規則は所有者のスタイルなので,信頼できるオーナーのリポジトリでだけ動かす(「Whose style」).
    - error の規則は `note` に修正方法を持つ.抑制ガードはすべてのプロバイダで動く.
-
**ブロック**(`agents/hooks/lint_format.py`,`agents/hooks/lib/static_rule_scan.py`)
- ast-grep が `severity: error` の指摘を返したら,PostToolUse の `{"decision":
"block", "reason": ...}` を返す.
- reason には指摘ごとに,規則 ID,場所,規則の `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.」
- error,指示文,advice の順に並べ,全体を 1
つのサイズ上限(`NOTIFICATION_LIMIT_BYTES`)に収める.advice は残りに収まる分だけ入れる.
- error 未満の指摘,linter
の診断,走査の失敗はブロックせず,従来どおり通知する.壊れた走査でエージェントを止めないため.出力が切り詰められても,終了コード 1(error
あり)ならブロックする.
- dsh は PostToolUse で `systemMessage` を読むので,ブロック時は同じ文を `systemMessage`
にも入れる(プロバイダのプロファイルがブロックの形式も決める).
- **共有規則は信頼できるオーナーのリポジトリでだけ動かす**(`static_rule_scan.py`)
- 共有規則(`agents/hooks/lint/sgconfig.yml`)は,チェックアウトの origin のオーナーを
`trusted_owners` が信頼している場合にだけ走る(`AGENT_TRUSTED_OWNERS` も同様).
- 判定するのはオーナーだけ.fork かどうかは問わない.fork かどうかは model rule
が何を読めるかに関わることで,誰のスタイルを当てるかには関わらない.問い合わせをしないので,オフラインでも編集のたびに待たされず,オーナー自身のリポジトリで規則が知らせずに止まることもない.
- それ以外のリポジトリ,リポジトリ外,origin が無い,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 自身(tree-sitter)に判定させる**.`ast-grep scan --stdin`
で言語ごとのコメントノードを探す.ブロックコメント,複数行文字列,YAML のブロックスカラー,Rust の raw
string,ヒアドキュメント,JS の `<!--` コメントを正しく扱える.
- 以前は言語ごとに手書きの字句解析をしていたが,文字列の形式を見落とす指摘が続いたため置き換えた.対象の拡張子はすべて ast-grep
が解析できる.
- ast-grep
は,走査するテキスト中の抑制をこの走査自体にも当てはめ,マーカーの下のコメントを隠す.そこで,語を同じ長さの別の語に置き換えてから走査する.設定は空の
`sgconfig.yml` を明示的に渡し,プロジェクトや親ディレクトリの設定は読まない.
    - マーカーは件数ではなく,「効く位置にあるか」と「指示と対象の規則」の組で比べる.1 行にある複数のマーカーは,すべて照合する.
- 範囲は,マーカーからコメントの終わりまで(Rust
の属性は閉じ括弧まで,複数行でも)とする.その中で比べるのは,指示と規則の一覧だけ.たとえば `nolint` は linter
の一覧,`noqa` はコード,eslint は `--` の前まで,biome はコロンの前まで,Rust の属性は `reason =
"..."` を除いた部分.理由文の誤字を直すだけなら通る.`ast-grep-ignore`
は,マーカーの後ろの語をすべて規則名として読むので,コメント全体で比べる.
- Rust
の属性の閉じ括弧は,文字列とコメントの中の括弧を数えずに探す.閉じていない属性はファイルの終わりまでを範囲とする.範囲は,同じ種類の次のマーカーの手前で止める(コメントの中のマーカーで,属性の範囲は切らない).
- 判定の時間はファイルの大きさに比例する(行とノードは二分探索,括弧は 1 回の走査).マーカーが 2 万個のファイルでも 1 秒未満.
- そのため,`//nolint:errcheck` を `//nolint` や `//nolint:govet`
に変えるなど,対象の規則を減らす・変える・加える変更は,新しいマーカーと同じく確認する.`noqa` のコード,`type: ignore`
のコード,eslint の規則(複数行のブロックコメントも),`allow` / `expect` の lint,shellcheck
のコードも同じ.
- 規則名を書かない `ast-grep-ignore`
はすべての規則を抑制するので,規則名の変更も確認する.文字列をコメントに変える変更(同じ行でも,前後の行の変更でも)も確認する.
        - マーカーの移動や削除,マーカーの横のコードの編集は通る.
- ast-grep の走査は,1 回の判定の中で 20 秒の期限を共有する(フックの上限は 30
秒).期限は判定の開始時に決まる.期限で打ち切った走査があれば,コメントが不明なので確認する.
-
ファイル全体で比べるときは,コメントの外の語は数えない(文字列は何も抑制しない).文脈の無い断片(完全一致しないハンクなど)では,コメントの中に入るかどうかを判断できないので,すべてのマーカーをどこにあっても数える.
    - 相対パスは,payload の `cwd`(プロバイダがツールを実行するディレクトリ)を基準に読む.
- Rust の `#[allow(...)]` / `#[expect(...)]` は,Rust
の文字列とコメントの中以外なら数える.マクロ本体の中も数える(展開されると効くため).Rust 以外のファイルでは数えない.
    - ast-grep が無いか失敗したときは,コメントかどうかを判定できない.その場合は次の 2 つを確認する.
        - マーカーのある行が新しく現れた場合.行頭のインデントも比べる(YAML のブロックスカラーから外す変更など).
- マーカーを含むテキストで,変更した行に文字列やコメントの区切り(引用符,`/*`,`-->` と `--!>`,`<<`,YAML の
`|` など)がある場合.
- シェルスクリプトで,マーカーと `<<` を含むテキストの行を変えた場合(heredoc
の終端は記号を持たない語なので,行からは見分けられない).
        - それ以外の,抑制とは関係のない編集は通す.
        - 残る抜け道:ast-grep が無い環境で,区切りを含まない行の変更でマーカーがコメントに変わる場合は検出できない.
- Edit / MultiEdit / エディタの `insert` / Write
は,ファイル全体に適用した前後で比べる(replace_all,行の一部の編集,MultiEdit
の後続の手順も含む).エディタ系ツールのフィールド(`old_str`,`new_str`,`file_text`)も読む.置換がファイルに当てはまらないときは,マーカーを含むファイルなら確認する.
    - apply_patch
- すべてのハンクが既存ファイルに完全一致するなら,適用後のファイル全体で比べる.適用器はまず完全一致を探すので,同じ位置に当たる.
            - Add File は新しい内容そのもので比べる.
            - ハンク中の空行は空の文脈行として扱う.
            - ヘッダ行は前後の空白を除いて読む.
        - 次の場合は位置を判定できないので,マーカーを含むファイルなら確認する.
- 完全一致しないハンク,`*** End of File` のチャンク,解釈できない行,完全一致が 2 か所以上ある場合.
- 同じファイルに 2 回届くパッチは確認する.セクションの重複でも,`Move to:` の移動先でも,別の綴りや大文字小文字の違いでも同じ.
- `Move to:` は移動元と移動先の両方で判定する.移動先で初めて効くマーカーがあれば,それ自体を新しい抑制として確認する.
- 該当するのは,移動元では検査しない拡張子のマーカーと,移動先の文法でだけコメント(または Rust の属性)になるマーカー.
- 判定には,パッチを当てた後の内容を使う(再構築できないときは既存の内容).同じパッチでマーカーを消してから移動するなら通る.
            - `.py` から `.go` のような単なる移動は通る.
- ファイル単位の抑制:ast-grep は,1
行目のマーカーの直後に空行があるとファイル全体を抑制する.この状態になる編集や,この状態のマーカーを変える編集は確認する.1
行目のマーカーは,コメントノードの中にあるときだけ数える(1 行目が `MARKER = "ast-grep-ignore"`
のような文字列なら数えない).
    - 拡張子は小文字にして比べる.行の区切りは ast-grep と同じく改行だけとする.
- **プロバイダへの配線**(`agents/hooks.json`)
    - Devin,Hermes,pi,dsh の編集前フックに `content suppression` を加えた.
    - これらのプロバイダは確認を求められないので,新しい抑制はブロックされる.ユーザーが例外を追加する前提で,意図した挙動.
- **規則テスト**(`tests/test_ast_grep_rules.py`):`severity: error` で `note`
の無い規則があると失敗する.

## ユーザーの決定

- 第三者のリポジトリ:案
(a).共有規則は信頼できるオーナーのリポジトリでだけ走らせてブロックし,それ以外では走らせない.リポジトリ自身の規則は従来どおり.
- 抑制ガードを Devin,Hermes,pi,dsh にも配線し,そこでは新しい抑制をブロックする.Go の `//nolint`
も対象にした.
- ブロックメッセージ:指摘ごとの規則 ID,場所,message,note と,回避を禁じる指示文 1 回.note の無い error
規則は規則テストで落とす.
- レビューの指摘は別の Issue に回さず,この PR で直す.
- やらないこと:回避を検出する jev-lint 規則と,回避コストに関する ADR の基準.

## 文章と規則の対応表

| 規則 ID | 元の場所 | 元の規則(原文) | 判定 | 実装 | 例のテスト | 元の文章 |
| -------- | -------- | ---------------- | ---- |
------------------------------------------------------ | ---------- |
-------- |
| (なし) | — | — | — | hook と ADR の変更のみで,文章を規則に置き換えていない | — | — |

## 戻し方

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 の #218 の後は通る.
- `ruff check`,`ruff format --check`,`ty
check`,`ls-lint`,ファイル行数(pre-commit):通過.
- 追加・更新したテストは,各項目とも実装前に失敗することを確認した.
-
ブロック(`tests/hooks/test_static_rules.py`,`tests/hooks/test_lint_format.py`)
        - error でブロックし,reason は指摘と指示文 1 回で,全体が上限に収まる.
        - 実際の ast-grep でもブロックする.問題のないファイルと,規則の対象外の言語はブロックしない.
        - 異常終了した走査はブロックしない.切り詰められても,終了コード 1 ならブロックする.
        - Codex と dsh のアダプタ経由でもブロックする.
    - 信頼判定(`tests/hooks/test_static_rules_trust.py`)
        - 共有規則が走るのは,信頼できるオーナーのチェックアウトだけ.
        - fork の問い合わせはしない.
        - 別オーナーでも,プロジェクト自身の規則は走る.
    - コメントの走査(`tests/hooks/test_comment_nodes.py`)
        - 抑制マーカーの直下のコメントも見つける.
        - 作業ディレクトリの `sgconfig.yml` を読まない.
        - 文字列はコメントにしない.JS の `<!--` はコメントとする.エンコードできないテキストは不明として扱う.
-
抑制ガード(`tests/hooks/test_guard_suppression.py`,`tests/hooks/test_guard_suppression_scope.py`)
        - Codex と自動セキュリティレビューが報告したケースは,すべてテストにした.
- 文字列からコメントへの変化:同じ行,ブロックコメント,Python の複数行文字列,YAML のブロックスカラー,Rust の raw
string,ヒアドキュメント,Go の `"//nolint"`,ast-grep が無いときのテンプレート文字列.
        - 同じ行の 2 つ目のマーカー.
-
対象の変更(`tests/hooks/test_guard_suppression_target.py`):`//nolint`,`noqa`,`type:
ignore`,eslint,`allow` / `expect`,shellcheck
で規則を減らす・変える・加える変更は確認し,移動,削除,横のコードの編集は通る.
- 対象の変更では,属性の中のコメントや文字列にあるマーカーや括弧,閉じていない属性も確認する.理由文だけの修正(8 種類のマーカー)は通る.
- 走査の期限(`tests/hooks/test_guard_suppression_budget.py`):ハングする ast-grep
でも,移動を含むパッチの判定が期限内に終わり,確認する.期限切れの結果は次の判定に持ち越さない.マーカーが多いファイルも 5
秒以内に判定する.import
から時間が経っても,判定の外の走査は期限切れにならない(`tests/hooks/test_comment_nodes.py`).
- ast-grep が無いとき(`tests/hooks/test_guard_suppression_unparsed.py`):YAML
のインデント変更と heredoc 終端の挿入は確認し,heredoc の無いスクリプトの無関係な編集は通る.
        - payload の `cwd` にある相対パスのファイルを読む.
        - Rust の属性:raw string からコードへの変化,マクロ本体,Python のコメントから Rust への移動.
- パッチ:` ***`
で始まる文脈行で区切りが終わらない,配置できないハンクの断片で文字列に見えるマーカー,文脈行がコメントに変わる場合,Add
File,空行,`*** End of File`,解釈できない行,複数の一致,同じファイルへの重複(別の綴り,大文字小文字,移動先).
        - 移動:両方で効くマーカーは通る.移動先でだけ効くマーカーは確認する.
        - ast-grep が無いときは,抑制と関係のない編集を通す.`--!>` の変更は確認する.
- 1 行目の文字列はファイル単位の抑制にならない.移動の途中でマーカーを消せば通る.完全一致しないハンクが引用符の中に語を加えると確認する.
- apply_patch のテストは `tests/hooks/test_guard_suppression_patch.py`
に分けた(ファイル行数の上限のため).
- プロバイダ(`tests/test_provider_adapters.py`):5 つのアダプタすべてで,新しい抑制がブロックされる.
- 規則テスト(`tests/test_ast_grep_rules.py`):note の無い error 規則を検出する.main の
error 規則 28 件すべてに適用している.

## レビュー対応

- Codex,claude-review,自動セキュリティレビューの指摘は,すべてこの PR
で修正した.各スレッドにはコミットを添えて返信し,resolve した.
- 以前の返信にあるコミット ID の一部は,rebase の前のもの.
- 修正したもの
    - dsh のブロック表示.
    - 文字列からコメントへの変化.ここから,手書きの字句解析を tree-sitter に置き換えた.
    - 複数行コメント,YAML のブロックスカラー,Rust の raw string.
    - `//nolint` などのコメントの指示の判定.
    - 同じ行の 2 つ目のマーカー.
    - パッチの文脈行と配置.
    - ast-grep が無いときの判定.安全側に倒しつつ,抑制と関係のない編集は止めない.
    - ブロック全体の大きさ.
    - 拡張子をまたぐ移動.
    - 信頼判定の問い合わせ待ちと,規則が知らせずに止まる問題.
    - Rust の属性.
- CodeQL の HTML
コメントの終わり(`--!>`),ファイル単位の抑制のコメント判定,移動先で効くマーカーの判定に使う内容,断片の数え方.
    - 抑制の対象の変更(`//nolint:errcheck` → `//nolint` など)と,理由文の修正での誤検知.
    - 走査のタイムアウトの積み重ね,マーカーの多いファイルでの二乗の処理時間,属性の範囲の切り方と括弧の対応.
- ` ***` で始まる文脈行,payload の `cwd`,配置できないハンクの断片,ast-grep が無いときのインデントと
heredoc.
- CI の test ジョブの失敗:走査の期限が import の時点で決まっていたため,遅い実行では判定の外の走査が期限切れになっていた.
- 変えていないもの
    - 走査が失敗したときにブロックしない点:ADR の方針(壊れた走査でエージェントを止めない)どおり.
- この PR で入れた変更について jev-lint が出した advisory
の指摘(`command-query-naming`,`error-message-names-operation`)
- `_adds`,`_insert_change`,`_scan_within_budget` は query の名前に改め,走査の副作用は
`_scan` に寄せた.
    - `_patch_changes` は,返す値で命名した query なので当てはまらない.
    - `lint_format.py` の `TypeError` の文言は,この PR より前からある.
    - 規則そのものの扱いは #196 で記録する.

## 制限

完全な構文解析が要る理論上の抜け道で,この PR では扱わないもの.

- ast-grep
が無いか失敗したときは,行単位の推測で判定する.区切りの記号を含まない行の変更でマーカーがコメントに変わる場合(シェル以外の言語)は検出できない.ast-grep
は CI と dev shell で必須.期限切れは常に確認する.
-
指示と規則の一覧は,ツールごとの書式を正規表現で近似して切り出す.ツールが受け付けるのに正規表現が拾わない書き方で規則を足すと,理由文として扱われて見落とす.ツールの構文解析器を使えば防げるが,ツールごとの依存が増える.
- Rust の属性の範囲は,ast-grep
の文字列とコメントのノードを除いて括弧を対応づける.マクロの中の不均衡な括弧のように,tree-sitter と rustc
の解釈がずれる箇所は追わない.
- heredoc の判定は `.sh` と `.bash` に限る.他の言語の heredoc(Ruby,Perl
など)は対象の拡張子に無い.

## フォローアップ

- なし.

## ユーザーの判断事項

- 信頼できないリポジトリでも,そのリポジトリの `sgconfig.yml` にある `severity: error`
規則はブロックする.その規則の `message` と `note` は,エージェントへの指示としてそのまま渡る.
    - ユーザーの決定(プロジェクト自身の規則は従来どおり)に沿って変えていない.ただし,ブロックはこの PR で新しく入る挙動.
    - この PR の前も,同じ文言は通知として渡っていた.
    - ブロックするかどうかと,文言の扱いを信頼判定に合わせるかどうかは,ユーザーの判断事項.

## マージ後すぐ直す指摘

この PR では直さず,マージ直後のフォローアップ PR で直す(#216 と同じ扱い).

- markdown セルを code セルに変える NotebookEdit
で,比較元に旧本文が入る.元の本文にあるマーカーが変わらないものとして扱われ,確認なしで通る.
- Rust の属性で,`reason = "..."` の項目自体の追加・削除まで比較から外れる.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
furedea pushed a commit that referenced this pull request Nov 18, 2026
🤖 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>
furedea added a commit that referenced this pull request Nov 20, 2026
## 概要

#196 の Go の項目を origin/main で確かめ,残っていた Go
のモデル規則(jev-lint,助言)の見逃しを直し,ユーザー決定(2026-11-19)に従って go-style の
`t.Parallel()` の文を戻した.Jev 規則は昇格しない(ADR-0027).

Refs #196

## 項目ごとの状態

| 出典 | 項目 | 状態 |
| --- | --- | --- |
| #190 | `go_sealed_interface_sumtype_decl`:`// sumtype:decl` を受け入れる |
対応済み(obsolete.規則は #216 の時点で削除済み) |
| #190 | `go_error_no_capitalized_message`:import path・シャドー |
対応済み(obsolete.同上) |
| #190 | `go_context_param_named_ctx` / `go_no_context_in_struct`:import
path | 対応済み(#216.標準 `context` を別名なしで import したファイルに限定) |
| #190 | `go_use_slog`:import path,引数・receiver・名前付き戻り値のシャドー | 対応済み(#216)
|
| #190 | `go_use_slog`:ローカル変数のシャドー | 対応済み(#216 で規則の `Limits:`
に記録.スコープ解析が要る) |
| #190 | `go_iota_enum_typed`:`iota + 1` などの式 | 対応済み(#216 で `Limits:`
に記録.構文では enum と区別できない) |
| #190 | `go_no_generated_mocks`:`//go:generate` 経由,`// Code generated
by` ヘッダー | 対応済み(#216) |
| #190 | `go_no_context_in_struct`:`*context.Context` | 対応済み(#216) |
| #190 |
`error-handled-once`:`slog.Default().Error(...)`,`log.Default().Printf(...)`
| **修正** |
| #190 | `error-handled-once`:receiver 名が `log` / `logger`
以外(`l`,`audit`),receiver の `Output` | **修正** |
| #190 | `error-handled-once`:入れ子のクロージャのログで親関数も選ばれる |
**修正**(ログ呼び出しに最も近い関数だけを選ぶ) |
| #190 | `severity: error` を hook のブロックに結びつける |
対応済み(`static_rule_scan.py` が severity error を error として扱う) |
| #190 | model rule 5 件の fixtures・eval・baseline | 対応済み(#244 で Go の 13
規則を当てはめ) |
| #191 | Go `construction-separate-from-execution`:`client.New(...)` |
**修正**(`errors` / `uuid` / hash / container などの標準の `New` は除く) |
| #191 | Go `no-exposed-mutable-collection`:複数戻り値 `([]string, error)` |
**修正** |
| #191 | Go `no-exposed-mutable-collection`:名前付きの slice / map 型 |
**修正**(同じファイルで宣言した型に限る.別ファイルの型は Limits) |
| #191 | selector が広く Go の getter も選ぶ | 変更なし(#196 の方針でモデル規則の matcher
は広く取り,criteria で判定する) |
| #191 | Go `no-comment-restating-code`:関数直前の doc comment | misc レーン(4
言語まとめて直す「コメントの位置」の項目) |
| #191 | Go `no-reaching-through-collaborators`:プロパティ連鎖 | misc レーン(4
言語まとめて直す Demeter の項目) |
| #190 | go-style の `t.Parallel()` の文 | **修正**(ユーザー決定により文を戻した) |
| #216 | ローカルで失敗する
`test_go_rules_select_the_functions_they_ask_about`,`test_main_is_thin_selects_func_main_of_package_main`
| 対応済み(origin/main で通る) |
| #194 | `test_main_is_thin_selects_...` が `command-query-naming` に指摘される
| 対象外(Python の規則の判定.py レーン) |

## Limits(レビューで記録したもの)

matcher を直すと baseline がまた無効になり,この PR では eval を再実行しない(ユーザーの指示)ため,規則ファイルの
`Limits:` に記録した(6de1d32d).

-
`error-handled-once`:ログに似た呼び出しも選ぶ(`http.Error`,`cmd.Output()`,`c.Error(err)`,`s.t.Fatal(...)`).自分で実行するクロージャ内のログ(`defer
func() { log.Error(err) }()`)は親関数を選ばない.引数付きで派生したロガー(`slog.With("k",
v).Error(...)`,logrus の
`log.WithError(err).Error(...)`)を見逃す(**見逃し**.後続).
-
`construction-separate-from-execution`:`log.New`,`slog.New`,`zap.New`,メソッドの
`tmpl.New("x")` も選ぶ.
- `no-exposed-mutable-collection`:`(Items, error)` や名前付きの `(items
Items)` など括弧で書いた結果リスト内の名前付き型と,別ファイルで宣言した型を見逃す(**見逃し**.次に eval
を回すときに直す後続).`*[]T`,`chan []byte`,`func() []string` も選ぶ.

## 判断が要るもの

- go-style の文の扱い:#190 は template-go の golangci-lint が覆う文を `t.Parallel()`
以外にも削除した(`testifylint` の `require` / `assert`,`usetesting` の
`t.TempDir()` / `t.Setenv()` など).ユーザー決定の方針(template でしか有効でない linter
の規則は文を残す)をこれらにも当てはめて戻すかを決めてほしい.この PR では明示された `t.Parallel()` だけを戻した.

## 検証

- `uv run pytest tests/test_model_rule_files.py`:選択のテスト 3
件を先に足して失敗を確認し,matcher の修正後に通った.
- `uv run pytest tests/test_model_rule_files.py`:17 件通過(baseline の
replay を含む).
- `jev-lint eval --accept -r 3`(ユーザーが 2026-11-19 に実行):3 規則とも fp / fn
0.閾値を fitted midpoint に合わせた.`error-handled-once` 0.37 → 0.41(最高の clean
0.06,最低の bad 0.75),`construction-separate-from-execution` 0.6(0.24 /
0.96),`no-exposed-mutable-collection` 0.57 → 0.59(0.24 /
0.93).`error-handled-once` と `no-exposed-mutable-collection` は blind のまま
`inconclusive:` を残した.
- レビュー:Codex P2(zerolog の `log.Error().Err(err).Msg(...)` の見逃し)は
a25d8c9 で修正.P1(baseline の無効化)は c27cb73 で解消.

## 計画との差

なし.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
furedea added a commit that referenced this pull request Nov 20, 2026
…es and the Stop resume (#260)

## 概要

#196 の misc グループ(bash / GitHub Actions,hook,共有の項目)を片付ける.bash・yaml のモデル規則
6 件で,見逃していた書き方を選ぶようにし,eval を取り直して cutoff を当て直した.Stop の resume が別の review
構成で再開してしまう不具合も直した.判断が必要な項目はない.

Refs #196

## 変更前と変更後

| 対象 | 変更前 | 変更後 |
| --- | --- | --- |
| `workflow-default-shell` / `cache-key-and-trust` | flow 形式の step(`-
{run: …}`,`steps: [{uses: …}]`)を選ばない | 選ぶ |
| `job-permissions-least-privilege` | 引用符付きの `"jobs":`,flow 形式の job の
`permissions` を選ばない | 選ぶ |
| `usage-help-and-error-exits` | `$#` を調べる `if`,getopts の bare な `h)`
を選ばない | 選ぶ |
| `function-variables-local-near-use` | `: "$((count++))"` を選ばない | 代入を含む
`$(( ))` を選ぶ(`$((1 + 2))` は選ばない) |
| `tracing-not-left-on-for-secrets` | `set -xe`,`set -euxo pipefail`
を選ばない(#243 の Limit) | 選ぶ.bad fixture を 1 件追加 |
| Stop の resume | 失敗後にコミット構成が変わっても(`git reset --soft`),保存した位置から再開し,未実行の
review を飛ばす | resume に review 構成(base・rules・files)の digest
を保存し,一致しなければ最初からやり直す |

## 検証

- [x] `tests/test_bash_and_yaml_model_rules.py`(新規,dry-run の選択テスト 15
件):変更前は 11 件失敗,変更後はすべて成功
- [x] `tests/hooks/test_model_rules_resume.py`:別構成の resume
で最初からやり直すテストを追加(変更前は失敗)
- [x] `jev-lint eval --accept`(ユーザーが実行,2026-11-19,3 passes):6 suite の
baseline を記録
- [x] `jev-lint eval --replay agents/hooks/lint/model-rules`:74 suite
がすべて as shipped
- [x] `uv run pytest`(jev-lint 0.7.0 を `PATH` に置く):6188 passed,2 skipped
- [x] `ruff check`,`ruff format --check`,`ty check`(pre-commit)

## eval の結果(3 passes,中央値)

| 規則 | tp / fp / fn | 最高の clean | 最低の bad | cutoff |
| --- | --- | --- | --- | --- |
| `bash/usage-help-and-error-exits` | 4 / 0 / 0 | 0.45 | 0.83 |
0.64(据え置き) |
| `bash/function-variables-local-near-use` | 4 / 0 / 0 | 0.17 | 0.79 |
0.49(据え置き,blind) |
| `bash/tracing-not-left-on-for-secrets` | 4 / 0 / 1 | 0.16 | 0.16 |
0.5(分離しない) |
| `yaml/cache-key-and-trust` | 4 / 0 / 0 | 0.20 | 0.94 |
0.57(据え置き,blind) |
| `yaml/job-permissions-least-privilege` | 3 / 0 / 0 | 0.40 | 0.91 |
0.64 → 0.65(blind) |
| `yaml/workflow-default-shell` | 4 / 0 / 0 | 0.41 | 0.86 | 0.62 →
0.63(`inconclusive:` を削除) |

- `job-permissions-least-privilege` の `inconclusive:` は,指示では削除だった.しかし
margin が 0.26 / 0.25 で jev-lint の blind 判定(0.25 以上)に当たり,削除すると replay
が失敗する.このため残し,数値だけ 0.28 から 0.25 に直した.
- `cost`:eval 1 回(6 suite,ユーザー実行).このセッションでは model に問い合わせていない.

## #196 の misc 項目

| 項目 | 状態 |
| --- | --- |
| `gha_workflow_permissions_deny_all`:引用符付きの `"jobs":`,ルート全体が flow
mapping | 対応済み(#216.引用符は修正,flow は `Scope:` に記録) |
| `bash_readonly_constant_name`:関数内の `readonly`,`declare -r` |
対応済み(#216.`declare -r` / `-gr` は検査,関数内の `readonly` は `Scope:` に記録) |
| `gha_job_timeout_minutes`:`jobs` が flow mapping,引用符付きの `"jobs":` |
対応済み(#216.引用符は修正,flow は `Scope:` に記録) |
| `gha_pinned_uses_version_comment`:`action.yml` | 対応済み(#216.`files:` に
`action.yml` を追加) |
| `gha_workflow_concurrency` の
`'on':`,`gha_workflow_default_shell`,`bash_strict_mode_header` | 不要(#194
でモデル規則に降格) |
| `.bats` を ast-grep で Bash として読むか | 対応済み(#216.有効化しないと決定) |
| `SUBJECT_CAP` | 対応済み(#246) |
| `scripts/bootstrap_server.sh` に ast-grep がない(#202) | 対応済み(#216) |
| 後段 review の失敗で毎ターン block する件,失敗理由,`skipped_files`,2 tier の順序のテスト(#191)
| 対応済み(#216) |
| resume が別の review 構成に当たる(#216 のレビュー) | **修正**(この PR) |
| `workflow-default-shell` の flow step | **修正** |
| `job-permissions-least-privilege` の引用符付き `"jobs":`,flow job |
**修正**(`jobs` そのものが flow mapping の場合は対象外.下の Limits) |
| `cache-key-and-trust` の flow step | **修正** |
| `usage-help-and-error-exits` の `$#`,bare な `h` | **修正** |
| `function-variables-local-near-use` の `: "$((count++))"` | **修正** |
| `tracing-not-left-on-for-secrets` のフラグ連結(#243 の Limit) | **修正** |
| `SKILL_NAMES` が `.` で始まるディレクトリを拾う | 対応済み(#214) |
| `test_main_is_thin_selects_…` を `command-query-naming` が指摘する |
対応しない.advisory な余分の指摘で,テスト名が `selects` なのは matcher の選択を検証するため |
| `error-message-names-operation` が
`guard_git.py:46`,`herdr_ownership.py:26` を指摘する(#216) | 対象外.guard 系 hook
は #197 / #255 の担当 |
|
`no-comment-restating-code`,`no-exposed-mutable-collection`,`no-reaching-through-collaborators`,`construction-separate-from-execution`(言語ごと)
| 各言語レーンの担当.規則ファイルが言語ごとに分かれていて,共有ファイルがない |

<details><summary>Limits と範囲</summary>

- Limit:`tracing-not-left-on-for-secrets` は,`set +x` のあと秘密の前で再び `set -x`
するケース(`bad_retraced_before_secret.bash:10`)を 0.16 と判定し,clean
と分離しない.advisory のまま rule.yml に記録した.
- Limit:`job-permissions-least-privilege` と `workflow-default-shell`
は,`jobs` 自体が flow mapping(`jobs: {build: {...}}`)の workflow
を選ばない.実際にはほぼ書かれない形.
- Limit:`usage-help-and-error-exits` の bare な `h)` は,getopts ではない `case`
の `h)` も選ぶ.モデル規則の matcher は広く取る方針(#196)なので,criteria で判定する.
- Limit(レビュー指摘,P2):`cache-key-and-trust` は,別のアクションの入力(`with: {uses:
actions/cache@v4}`)も選ぶ.余分な subject で,block 形式にも以前からある.祖先の条件で step の
mapping に限る修正は matcher を変えて eval の取り直しが要るため,次の eval で直す.
- Limit(レビュー指摘,P3):`function-variables-local-near-use` は,`$(( flags <<=
1 ))` のように `<<=` / `>>=` で代入する `$(( ))` を選ばない.次の eval で `(<<|>>)=` を加える.
- Limit(#243 から継続):`script-constants-readonly`
は,同じ変数をトップレベルで再代入するスクリプトで余分に指摘し得る.
- 古い receipt(`layout` なし)の resume は,一致しないものとして扱い,最初からやり直す.
- 範囲外:Jev 規則の昇格(ADR-0027),guard / permission hook,#181,release.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant