Skip to content

fix(hooks): remove model-rule false positives with principles and eval fixtures - #163

Merged
furedea merged 9 commits into
mainfrom
fix/74-model-rules-false-positives
Nov 11, 2026
Merged

furedea merged 9 commits into
mainfrom
fix/74-model-rules-false-positives

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

概要

Stop で動くモデル判定(M-05,M-21)の誤検知を,原因ごとに 1 か所ずつ直しました.直し方は,例を eval の fixtures に入れ,ルールの文章には原則だけを書く形です.

  • fixtures と expect.yml を Python / TypeScript の M-05,M-21 に追加しました.実際に出た誤検知を「違反ではない例」に,本当の違反を「違反の例」に入れています.
  • M-05:criteria."false" を原則に書き直しました(はっきり「読むだけ」か「何かを変える」かを示す動詞だけが約束になり,それ以外の動詞は何も約束しません).動詞の例は増やしていません.
  • M-21:送る範囲(state)を local から located に変えました.
  • M-05 のカットオフを,fixtures で当てはめた値にしました(Python 0.76,TypeScript 0.79).
  • eval の baseline.json を保存しました.jev-lint eval --replay はモデルへの問い合わせなしで確認できます.この replay を pytest(tests/test_model_rule_files.py)で実行し,fixtures の行の移動やカットオフの変更で CI が失敗するようにしました.
  • fixtures を ruff,ty,vulture から除外しました(意図的な違反コードのため.vulture は絶対パスに一致するパターンにしています).

Refs #74

計画:#74 (comment)

原因の分類と直し方

誤検知 原因 直した場所
M-21 Python provider_adapter.py 付近(別関数が組んだメッセージ) 文脈不足 state: located(Python / TypeScript)
M-21 project_targets(内側の raise を同じ関数で捕捉して包み直す) 文脈不足 同上.eval の違反ではない例に追加
M-05 _check_paths,Review.judge 定義が曖昧(「check」「judge」は読むとも変えるとも約束しない) criteria."false" を原則に書き直し
M-05 の違反の例と違反ではない例が重なる カットオフ threshold を当てはめ値に
M-05 load_port 現在の main に存在しないため対象外 なし

M-21 の state の比較(Python の fixtures 8 件,3 回)

state 偽陽性 見逃し cleanTop トークン(--dry-run) 判断
local 1 0 0.56 9,996 補助関数が見えず誤検知
located 0 0 0.18 11,694 採用.誤検知が消え,違反との差が最も広い
graph 1 0 0.62 11,430 呼び出し関係だけではメッセージの中身が分からず誤検知

located は 1 ケースあたり約 $0.0004 で,費用の差はわずかです.

eval の記録(ラウンド 1〜4)

ラウンド 変更 M-05 Python M-05 TypeScript M-21 Python M-21 TypeScript
1 baseline 今のルール tp 4 / fp 1 / cleanTop 0.52 tp 4 / fp 0 / cleanTop 0.47 tp 4 / fp 1 / cleanTop 0.56 tp 4 / fp 1 / cleanTop 0.52
2 M-05 を原則のみに,M-21 を located tp 4 / fp 2 / cleanTop 0.93 tp 4 / fp 2 / cleanTop 0.94 tp 4 / fp 0 / cleanTop 0.20 tp 4 / fp 0 / cleanTop 0.14
3 M-05 に read / effect の定義を戻す tp 4 / fp 1 / cleanTop 0.59 tp 4 / fp 1 / cleanTop 0.63 tp 4 / fp 0 / cleanTop 0.28 tp 4 / fp 0 / cleanTop 0.14
4 M-05 の fixtures を違反 8・違反ではない例 8 に増やす tp 8 / fp 2 / cleanTop 0.58 / fitted 0.76 tp 8 / fp 2 / cleanTop 0.66 / fitted 0.79 (変更なし) (変更なし)
確定 M-05 の threshold を 0.76 / 0.79 に tp 8 / fp 0 / fn 0 tp 8 / fp 0 / fn 0 tp 4 / fp 0 / fn 0 tp 4 / fp 0 / fn 0
  • ラウンド 2 は,原則だけに書き直した M-05 が悪化しました(記憶する query と,結果を返す command が再び誤検知).この 2 つは例外ではなく,read と effect の定義なので,定義として戻したのがラウンド 3 です.
  • 確定行は,ラウンド 4 の実測値(clean の最大 0.58 / 0.66,違反はすべてそれより上)を,当てはめた threshold で採点し直したものです(jev-lint eval --accept-last と --replay.モデルへの問い合わせなし).
  • M-05 の fixtures には,違反ではない例(平均の最大 0.58 / 0.66)と違反(平均の最小 0.91 / 0.90)の間に入る例がありません.そのため 0.62〜0.90(TypeScript は 0.68〜0.89)のどのカットオフでも eval の結果は同じで,0.6〜0.75 で採点される軽い違反は見逃される可能性があります(claude-review の指摘.ルールのヘッダに記載).境界に寄せた違反の fixture を足して当てはめ直すのは,次のラウンドの課題です.
  • Python M-21 のカットオフは 0.5 のままです(偽陽性 0,cleanTop 0.28).
  • TypeScript M-21:レビュー指摘で projectTargets(内側の throw を捕捉して包み直す)の fixture を足したところ,平均 0.50(3 回で 0.51 / 0.55 / 0.43)とカットオフ 0.5 に重なり,判定が揺れました.これはカットオフの問題として扱い,当てはめ値 0.75 にしました(違反 4 件は 0.95 以上).--replay で揺れ 0,4 スイートとも baseline どおりです.
  • 同じ fixture で TypeScript M-21 は境界から遠くなくなったため,先に付けた inconclusive は不要になり(--replay が stale として指摘),外しました.M-21 TypeScript の違反側の余裕は 0.20,違反ではない側は 0.25 で,まだ小さい部分は残ります.

規則の対応表(#74)

規則 ID 元の場所 元の規則 判定 実装 例のテスト 元の文章
M-05 command-query-naming agents/AGENTS.md 名前は command には副作用を,query には返す値を表す model(Python / TypeScript) agents/hooks/lint/model-rules/{python,typescript}/command-query-naming/rule.yml 同フォルダの fixtures/ と expect.yml(各 16〜17 件) 昇格まで残す
M-21 error-message-names-operation agents/skills/python-style ほか エラーメッセージは何をしていて何に対してかを示す model(Python / TypeScript) agents/hooks/lint/model-rules/{python,typescript}/error-message-names-operation/rule.yml 同フォルダの fixtures/ と expect.yml(各 8〜9 件) 昇格まで残す

指摘は助言として返すだけで,止めません(ADR-0021 のまま).

検証

  • uv run pytest -n auto tests:4738 件通過,1 件スキップ(リベース後)
  • ruff check,ruff format --check,ty check:通過(fixtures は除外)
  • jev-lint rules -R agents/hooks/lint/model-rules:6 件読み込み,エラー 0
  • jev-lint eval --replay agents/hooks/lint/model-rules:4 スイートとも保存した baseline のとおり
  • モデルへの eval(ラウンド 1〜4)は利用者が実行しました.鍵はエージェントが読んでいません.

計画との差分

🤖 Generated with Claude Code

furedea and others added 5 commits November 11, 2026 23:52
Add fixtures and expect.yml for command-query-naming and
error-message-names-operation: the false positives found in agent-config
(check_paths, Review.judge, a message built by a helper) as clean cases, and
real violations as defects. Exclude the planted fixtures from ruff, ty and
vulture.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…wider state

command-query-naming: rewrite criteria "false" as one principle: only a verb
that unambiguously promises a pure read or an effect makes a promise; any
other verb promises neither. No verb list is added.

error-message-names-operation: send the whole file (state located). The
message is often built by a helper beside the raise, which the local state
did not show; located had no false positive on the eval fixtures and graph
still had one.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The principle-only rewrite regressed the eval: a memoizing query and a
command that returns its own result were flagged again. State both as part of
what a promise means, not as examples. Add a clean fixture for a raise that
the same function catches and wraps.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Four more clearly violating and two more conforming cases per language
(8 violations and 8 conforming in total), so the fitted cutoff does not rest
on four defects.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…lines

On the 8 violating and 8 conforming fixtures per language, the highest
conforming case scored 0.58 (Python) and 0.66 (TypeScript) and every
violation scored above it. Set the cutoffs to the midpoints of those gaps
(0.76, 0.79) and say so in the rule headers. Accept the last eval runs as
baselines so that `jev-lint eval --replay` can check the rules without
requests. The TypeScript error-message rule declares why its corpus is blind
at the boundary.

Refs #74

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

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 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-11T15:58:39.996534Z 16493df 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

No blocking findings (P0: 0, P1: 0).

Checked:

  • Every expect.yml line number matches the subject's start line in its fixture file (Python and TypeScript, M-05 and M-21).
  • The scores in baseline.json support the labels: in every suite, all violations score above all conforming cases, and the fitted cutoffs 0.76 / 0.79 fall inside that gap.
  • Fixtures are already excluded from Stop review (model_rules_files.RULE_FIXTURES) and from check selection (check_selection.MODEL_RULE_FIXTURES). The new ruff, ty and vulture excludes cover the */*/fixtures layout.
  • The state: located change is consistent across both languages.

Not verified: I could not fetch jev-lint 0.7.0 here, so two things are untested: that jev-lint review -R <rules dir> ignores the new expect.yml and baseline.json, and that --replay accepts a baseline recorded with at: 0.5 while the rule now says threshold: 0.76. A quick local --dry-run of the Stop hook command would confirm both.

Findings:

  • P3 (inline): the fit comments in the M-05 rule.yml files misquote the highest conforming score (0.58 / 0.66, but the baselines show 0.62 / 0.68). Also, every violation fixture scores ≥ 0.89, so the eval cannot show whether a moderate violation is caught at the new cutoff. Consider adding a borderline fixture or an inconclusive note, as was done for TypeScript M-21.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9607619394

ℹ️ 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".

… range

The headers quoted means without saying so. Give the means and the worst
single pass, and record that no fixture lies between the conforming and the
violating cases, so the eval cannot place the cutoff within that range.

Refs #74

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

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

レビューのまとめ

止める必要のある指摘(P0 / P1)はありません.

確認したこと

  • 4 つの expect.yml の行番号はすべて,fixtures の対象の def / function / メソッドの行と合っていました.M-21 の対象は raise / throw を含む関数で,補助関数の secret_path_reason / secretPathReason は raise しないため対象外です.
  • ラベルは各 fixture のコメントと合っていました.
  • pyproject.toml の除外設定:fixtures には意図的に未使用の引数(例:set_timeout の config)がありますが,ruff,ty と vulture を含む audit のジョブは CI で通っています.
  • threshold の 0.76 / 0.79 は,ヘッダに書かれた差の範囲の中にあります.

指摘

  • P3:TypeScript M-21 に,Python の project_targets にあたる「同じ関数で捕捉して包み直す throw」の違反ではない例がありません(インラインコメント参照).

確認できなかったこと

  • state: located と inconclusive は外部の jev-lint が解釈するため,このリポジトリの中では確かめられませんでした.PR 本文の jev-lint rules / eval --replay の結果を信頼しています.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 42e5862f8c

ℹ️ 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 and others added 2 commits November 12, 2026 00:19
…ssage suite

Mirror the Python projectTargets case: a throw inside a try that the same
function catches and wraps, so a regression on that pattern shows in the
TypeScript eval too.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ror fixture

The projectTargets fixture scored 0.50 on average and flipped across the 0.5
cutoff, while every violation scored 0.95 or more. Fit the cutoff to 0.75 and
accept the new baseline. The corpus is no longer blind at the boundary, so the
inconclusive note is dropped.

Refs #74

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

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings (0 × P0/P1). One P2 is posted inline.

What I checked:

  • Every expect.yml line points at the right subject. I checked all 4 suites (16 + 9 + 16 + 9 cases). Each line: matches the def or function line of the intended fixture function.
  • The fixtures stay out of linting and review. The excludes for ruff, ty and vulture use agents/hooks/lint/model-rules/*/*/fixtures. The Stop-hook review skips fixtures through RULE_FIXTURES in model_rules_files.py. The file names pass ls-lint.
  • The state: located and criteria changes do what the PR says. I found no correctness problems in the rule YAML.

Finding:

  • P2: nothing in CI runs jev-lint eval --replay. If a fixture line moves or someone edits a threshold, the baselines silently stop matching. The tests/test_model_rule_files.py docstring also still calls the cutoffs unfitted. (Inline on python/command-query-naming/rule.yml.)

Minor and not posted: the header of python/error-message-names-operation/rule.yml still says "unfitted, as for command-query-naming", but command-query-naming is now fitted.

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

ℹ️ 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 pyproject.toml Resolved
Add a test that runs `jev-lint eval --replay` over the model rules, so a moved
fixture line, an edited cutoff or criteria, or a stale exemption fails CI
without a key. Match the vulture fixture exclusion against absolute paths: the
relative pattern did not exclude the fixtures when vulture saw absolute paths.
Update the cutoff comments and the test docstring that still called the
cutoffs unfitted.

Refs #74

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

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings (P0: 0, P1: 0, P2: 0, P3: 0).

What I checked:

  • expect.yml line anchors: every line: in all four expect.yml files points at the right def / function / method line in its fixture. The clean/bad split matches the PR description (M-05: 8/8 per language; M-21: 5 clean / 4 bad).
  • rule.yml changes: state: located for M-21 (Python and TypeScript). Fitted M-05 cutoffs of 0.76 and 0.79, and a TypeScript M-21 cutoff of 0.75; the header comments match the eval numbers in the description. The rewritten M-05 criteria."false" is the same in both languages.
  • Lint exclusions in pyproject: the ruff extend-exclude, ty exclude and vulture exclude patterns cover model-rules/*/*/fixtures. The audit (vulture), lint and typecheck CI jobs pass on this head.
  • New test: test_every_saved_eval_baseline_still_scores_as_accepted runs jev-lint eval --replay without a key. It guards against fixture line drift and changes to the cutoff or criteria, which covers the changed behavior.

A non-blocking risk the PR already records: M-05 has no fixture between the clean and bad scores, so a violation scoring about 0.6–0.75 would now be dropped silently. The plan to add a borderline fixture and refit is the right follow-up.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 16493df7d8

ℹ️ 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 b07fc4e into main Nov 11, 2026
24 checks passed
@furedea
furedea deleted the fix/74-model-rules-false-positives branch November 11, 2026 16:10
furedea pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.1.2](v0.1.1...v0.1.2)
(2026-11-12)


### Features

* **hooks:** add Go and Rust model rules with eval fixtures
([#158](#158))
([9731488](9731488))
* **hooks:** show model-rule timing and skip rule fixtures
([#157](#157))
([d0c32ae](d0c32ae))
* **hooks:** show the model rules as one result line with cost
([#170](#170))
([41b9033](41b9033))


### Bug Fixes

* **hooks:** allow a jq filter after read-only GraphQL queries
([#180](#180))
([cfb80d8](cfb80d8))
* **hooks:** keep model-rule eval fixtures out of Stop test verification
([#160](#160))
([a4f1c6c](a4f1c6c))
* **hooks:** read paths literally in every jev-lint child process
([#173](#173))
([0d2c683](0d2c683))
* **hooks:** remove model-rule false positives with principles and eval
fixtures ([#163](#163))
([b07fc4e](b07fc4e))
* **hooks:** report one count per runner in the Stop test lines
([#177](#177))
([0f36b82](0f36b82))
* **hooks:** take the model-rule cached count from the dry-run plan
([#167](#167))
([c87fdfd](c87fdfd))

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