Skip to content

feat(lint): judge ADR rationale with Jev - #228

Merged
furedea merged 4 commits into
mainfrom
feat/judge-adr-rationale
Nov 17, 2026
Merged

furedea merged 4 commits into
mainfrom
feat/judge-adr-rationale

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

概要

ADR の書き方の質を Jev で判定する advisory ルールを 2 つ追加し,Stop hook がそれらに渡す ADR を「新規または本文が変わったもの」に限る.

変更

  • agents/hooks/lint/model-rules/markdown/adr-states-why/ と adr-options-are-real-alternatives/(rule.yml・fixtures/・expect.yml).subject は文書全体で,cutoff は開始値 0.5 のまま.
  • model_rules_files.select() が since を受け取り,docs/adr/[0-9]*.md のうち新規または front matter を除いた本文が変わったものを Selection.adrs に入れる.front matter だけの変更と ADR 以外の Markdown は入らない.
  • model_rules_gate:adr-* のルールは rule_tiers から外し,Selection.adrs だけを渡す review を最後に追加する(jev-lint は Text ルールをパスで絞れないため hook 側で絞る).
  • docs/DESIGN.md に説明を追加.agents/skills/adr/SKILL.md は変更しない(promote 時に削除,ADR-0021).
  • テスト:tests/hooks/test_model_rules_adrs.py,tests/test_model_rule_files.py に --dry-run の 1 件.

cutoff の fit

jev-lint eval --accept(3 passes,約 0.0024 USD)の結果.cutoff は既存ルールの慣例(fixtures が広い余白で分かれるなら 0.5 のまま,例:error-message-names-operation)に従い 0.5 を保つ.

ルール fixtures tp / fp / fn 最高の clean 最低の bad fit の中点
adr-states-why bad 4・clean 5 4 / 0 / 0 0.03 0.91 0.47
adr-options-are-real-alternatives bad 4・clean 6 4 / 0 / 0 0.13 0.94 0.55

fixtures は 9〜10 件と少なく較正とは言えないため,ルールは advisory のままで,adr skill の文も残す.replay は「境界の fixture が無く劣化を検出できない(blind)」と判定したので,各 rule.yml に inconclusive: で理由を宣言した.境界の fixture は今後の課題.

範囲外として扱うもの

promote(blocking 化),skill の文の削除,CI での Jev 実行,ADR 以外の Markdown のルール,jev-lint 本体,他リポジトリの ADR 形式.

Closes #227
Refs #169

🤖 Generated with Claude Code

Add the advisory rules adr-states-why and adr-options-are-real-alternatives
with fixtures built from existing ADRs and synthetic defects, review them
apart from the other rules, and give them only the ADRs under docs/adr/ that
are new or whose body changed. The cutoffs are not fitted yet.

Refs #169, Closes #227

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

furedea commented Nov 17, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 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-17T15:19:54.093894Z abc9ebf 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.

Comment thread agents/hooks/lib/model_rules_files.py Resolved
@github-actions

Copy link
Copy Markdown

Review summary (read-only, static; I couldn't run jev-lint or pytest in this environment).

  • P1 — The two new ADR rules have no baseline.json, so test_every_saved_eval_baseline_still_scores_as_accepted fails. This blocks the merge until jev-lint eval --accept has been run and the baselines are committed.
  • P2 — The committed-side ADR selection compares the working-tree text with record.head instead of comparing HEAD with it. A front-matter-only commit can then reach the ADR rules, and the same ADR can be judged twice.

The rest looks right:

  • rule_tiers leaves out the adr-* folders.
  • The ADR reviews are added only when adrs is not empty, so the review can never fall back to 'all paths'.
  • A symlinked ADR is still withheld.

The new tests cover selection and the committed ADR review. The uncommitted ADR review branch in _Changes.reviews has no test.

🤖 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: d0b78b5080

ℹ️ About Codex in GitHub

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

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

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

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

Comment thread agents/hooks/lib/model_rules_files.py Resolved
Add baseline.json for adr-states-why and adr-options-are-real-alternatives,
keep the cutoff at 0.5, and declare the corpus blind in each rule.
@furedea-agent
furedea-agent Bot marked this pull request as ready for review November 17, 2026 14:19
@furedea

furedea commented Nov 17, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/model_rules_files.py Resolved
@github-actions

Copy link
Copy Markdown

Review summary (read-only)

No blocking findings (P0/P1: 0).

  • P3: model_rules_files._is_changed_adr compares the working-tree file with since. For the committed review, it should compare HEAD with since, so that it matches the record.head...HEAD diff that review judges. Today a front-matter-only commit followed by an uncommitted body edit gets judged in the committed review, and the ADR is judged twice. Details are in the inline comment.

Checked and found fine: ADR rules are left out of both tiers and are reviewed last, so the general rules keep their claim on the subject cap and _cut_short at position 0 is not affected. _inputs still fingerprints the new rule files. The docs/adr/[0-9]*.md match leaves out the index, nested folders and fixtures. select still withholds symlinked ADRs. The test that compares tier subjects with the whole directory still holds, because its sample repo has no Markdown.

I could not run the tests in this environment (command approval was denied).

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 963a714c92

ℹ️ About Codex in GitHub

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

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

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

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

The committed review judges base...HEAD, so an ADR's body must be compared
between those revisions; the working tree belongs to the uncommitted review.
@furedea

furedea commented Nov 17, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Automated review (read-only): no findings.

What I checked:

  • model_rules_files.select / _is_changed_adr: the ADR glob (docs/adr/[0-9]*.md with full_match, so nested folders are excluded), front-matter stripping, the committed span (record.head → HEAD, read via git show) and the uncommitted span (working tree vs HEAD), and the handling of new, reverted and front-matter-only cases.
  • model_rules_gate: rule_tiers leaves out the adr-* folders, the tuned/untuned split still works, and an empty tier list comes back when only ADR rules exist. The ADR reviews are appended last with only Selection.adrs, so resuming by position stays deterministic and the tuned tier still claims the subject cap first.
  • Tests cover selection across both spans, symlink withholding, separating the tiers, review ordering and the --dry-run subject count.

I couldn't run the test suite in this environment, so this is based on reading the code only.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 4d1ecdf33c

ℹ️ 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-agent

furedea-agent Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@furedea

furedea commented Nov 17, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings (P0/P1: 0).

What I checked:

  • model_rules_files.select / _is_changed_adr: The path filter docs/adr/[0-9]*.md with full_match leaves out the index, nested folders and other Markdown. The committed review compares record.head with HEAD and the uncommitted review compares HEAD with the working tree, so each review's ADR selection matches the change that review judges. A new file, or a repository with no HEAD, counts as new. _body handles CRLF fences and a missing closing fence. git show rev:path does not apply textconv by default, and paths starting with - are filtered out earlier by _verdict, so I see no injection risk.
  • model_rules_gate: Both rule_tiers cases (tuned+untuned, and one kind) leave out the adr-* folders. ADR reviews are added only when adrs is non-empty, so an empty paths never widens them to the whole diff. The receipt fingerprint covers the new rule .yml files, so an older receipt cannot be reused with a resume index that no longer matches.
  • Tests: Selection has good coverage: front-matter-only changes, a body reverted after commit, the span used for comparison, symlinked ADRs, and tier exclusion. Existing whole-directory dry-run tests don't change Markdown, so the new rules don't change their counts.

Minor observations, not worth inline comments: a renamed ADR (git mv) with an unchanged body counts as "new" because --no-renames is used. ADR reviews run last and share the subject cap, so a large session can push them out. Both are acceptable while the rules stay advisory.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: abc9ebf2b5

ℹ️ 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 cf1c0a3 into main Nov 17, 2026
29 checks passed
@furedea
furedea deleted the feat/judge-adr-rationale branch November 17, 2026 16:52
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 19, 2026
## 概要

bash 6・yaml 4 の jev-lint 規則に fixtures と `expect.yml` を加え,`jev-lint eval`
で測った fitted midpoint を cutoff にする.分離しなかった規則は ask / criteria
を書き直した.昇格は無し(全規則 advisory のまま,skill の文も残す).判断してほしいのは下の「昇格しない理由」.

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

| 規則 | fixtures | tp / fp / fn | 最高の clean | 最低の bad | cutoff | 備考 |
| --- | --- | --- | --- | --- | --- | --- |
| `bash/strict-mode-header` | bad 4・clean 4 | 4 / 0 / 0 | 0.15 | 0.97 |
0.56 | blind(`inconclusive:`) |
| `bash/usage-help-and-error-exits` | bad 4・clean 5 | 4 / 0 / 0 | 0.42 |
0.84 | 0.64 | |
| `bash/function-variables-local-near-use` | bad 4・clean 5 | 4 / 0 / 0 |
0.18 | 0.80 | 0.49 | 書き直し・`located`・blind |
| `bash/script-constants-readonly` | bad 3・clean 4 | 3 / 0 / 0 | 0.04 |
0.96 | 0.5 | 書き直し・`located`・blind |
| `bash/working-directory-by-responsibility` | bad 3・clean 6 | 3 / 0 / 0
| 0.10 | 0.33 | 0.23 | 書き直し |
| `bash/tracing-not-left-on-for-secrets` | bad 4・clean 6 | 3 / 0 / 1 |
0.17 | 0.13 | 0.5 | **分離しない**,Limit を記録 |
| `yaml/cache-key-and-trust` | bad 4・clean 5 | 4 / 0 / 0 | 0.20 | 0.94 |
0.57 | blind |
| `yaml/job-permissions-least-privilege` | bad 3・clean 5 | 3 / 0 / 0 |
0.36 | 0.92 | 0.64 | blind |
| `yaml/workflow-concurrency` | bad 4・clean 4 | 4 / 0 / 0 | 0.03 | 0.76
| 0.4 | blind |
| `yaml/workflow-default-shell` | bad 4・clean 5 | 4 / 0 / 0 | 0.35 |
0.87 | 0.62 | 書き直し・blind |

書き直しの内容(最初の eval で分離しなかったもの):

| 規則 | 最初の eval | 原因と変更 |
| --- | --- | --- |
| `script-constants-readonly` | clean 4 件すべて 0.69〜0.77 | `state: local`
では代入より後の行が見えない → `located`,criteria で「ファイル全体で名前を探す」と明記 |
| `function-variables-local-near-use` | 文書化された出力変数を誤検出,`for` の変数を見逃し |
関数上のコメントが見えない → `located`,`for`・`read` 等の名前も個別に `local` が要ると明記 |
| `workflow-default-shell` | `shell: sh` 等の bad 3 件を見逃し | ask が「shell
が未設定」しか問うていなかった → 実効 shell を求めて pipefail の有無を問う |
| `tracing-not-left-on-for-secrets` | 後で再び有効化するファイルの最初の `set -x` を誤検出 |
判定範囲を「この `set -x` から次の `set +x` まで」に限定 → 誤検出は消えたが,再有効化側の見逃しが残った |
| `working-directory-by-responsibility` | `popd` の無い `pushd` を 0.23 で見逃し
| criteria に明記 → 0.33 に上がったが余白は小さい |

## 昇格しない理由

- fixtures は各 7〜10 件で,ADR-0021 の「より大きな corpus で fit してから昇格」に届かない.
- 今の Stop hook は `jev-lint review --fail-on error` の非 0
終了を「実行失敗」の通知として扱う(`model_rules_run.py` の `_Child.run`).`severity: error`
にすると finding が block されず `exited with status 1` の notice になるので,昇格には hook
側の対応が先に要る.
- したがって `bash-style` / `github-actions-style` の文は消していない.AGENTS.md
から消せる文も無い.

## 検証

- [x] `jev-lint eval --accept`(ユーザー実行,2
回):上表のとおり.`tracing-not-left-on-for-secrets` 以外は全 fixture を正しく判定
- [x] `jev-lint eval --replay agents/hooks/lint/model-rules`:22 suite
すべて as shipped
- [x] `REQUIRE_JEV_LINT=1 uv run pytest
tests/test_model_rule_files.py`:14 passed
- [x] 各 `expect.yml` の行が matcher の subject 行と一致することを ast-grep で確認
- [x] lefthook(shfmt・shellcheck・ls-lint・commitlint)通過

## 費用と subject 数

- eval:記録済み baseline の合計 $0.0078,上書きした最初の 5 suite の分(dry-run 見積もり約
$0.0027)を含め約 $0.011.
- Stop 1 回の最悪ケース(このグループの規則を対象ファイル 32 件すべてに当てた `jev-lint check --dry-run
-c none`):151 subjects,34 requests,約 $0.0057.上限 250
に収まる(内訳:`function-variables-local-near-use` 46,ADR 規則 各
26,`workflow-default-shell` 19).`located` への変更で bash 2 規則の 1 subject
あたりの token は増える(dry-run で eval 1 回あたり +$0.0003 程度).

<details><summary>範囲・前提・Limits</summary>

- shell の fixtures は `.bash`:CI の shellcheck / shfmt は `*.sh`
だけを対象にするため,意図した違反で CI が落ちない.jev-lint は `.bash` も Bash として選ぶ.
- markdown の 2 規則は #228 で fit 済みのため変更なし.#196 の verification notes に bash
/ yaml / markdown 向けの項目は無い.
- Limit:`tracing-not-left-on-for-secrets` は `set +x` の後で再び `set -x`
を有効にしてから秘密を展開する場合を見逃す(0.13).
- Limit:`working-directory-by-responsibility` の cutoff 0.23 は clean の最高
0.10 との余白が小さい.
- Limit(レビュー指摘):`tracing-not-left-on-for-secrets` の
matcher(`-[a-zA-Z]*x\b`)は `set -xe`・`set -euxo pipefail` を subject
にしない.`-[a-zA-Z]*x[a-zA-Z]*` に広げると全 spelling を選ぶことを確認したが,matcher の変更は
baseline を無効にし新しい eval が要るため,この PR では変えない.次の eval と同時に matcher を広げ,`set
-euxo pipefail` の bad fixture を足す.
- Limit(レビュー指摘):`model_rules_gate.rule_tiers()` は baseline の有無だけで tuned
tier を決めるので,分離しない `tracing-not-left-on-for-secrets` も subject
上限を先に使う.baseline を外すと replay テストが落ちるため残す.全レーンの後はほぼ全規則が baseline を持ち tier
の差は小さくなるが,tier の基準(分離したかどうか)は hook 側の課題.
- Limit(レビュー指摘):`script-constants-readonly`
は同じ変数をトップレベルで複数回代入するスクリプトで,最後の代入を定数違反と誤検出し得る(criteria
が後続の変更しか見ない).criteria の変更も新しい eval が要るため,余分な指摘として記録だけする.
- `docs/DESIGN.md` の「Five cutoffs are fitted
...」の文は他レーンと共有の記述なので触っていない.全レーン終了後に親で更新が要る.
- jev-lint 本体,hook,他言語の規則は範囲外.

</details>

Refs #220

🤖 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.

feat(lint): judge ADR rationale and considered options with Jev

1 participant