Skip to content

feat(lint): fit the Python model-rule cutoffs to eval fixtures - #240

Merged
furedea merged 5 commits into
mainfrom
feat/fit-jev-rules-python
Nov 19, 2026
Merged

furedea merged 5 commits into
mainfrom
feat/fit-jev-rules-python

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

概要

Python の jev-lint 規則 19 件すべてに fixtures と expect.yml を用意し,jev-lint eval(3 passes)で精度を測った.仮の 0.5 だった cutoff を fitted midpoint に置き換え,根拠を各 rule.yml のコメントに書いた.親セッションの指示に従い,この回はどの規則も昇格させず(全規則 advisory のまま),python-style skill の文章も消していない.

変更

  • 17 規則に fixtures/ と expect.yml を追加した(command-query-naming と error-message-names-operation は既存).どの規則も 6〜10 件で,判定の分かれやすい clean を入れている.located の規則はファイル全体がモデルに渡るため,ラベルが漏れないよう fixture のコードには Bad/Clean のコメントを書かず,理由は expect.yml の why に書いた.
  • 19 規則の baseline.json を追加・更新した(ユーザー実行の eval --accept).
  • cutoff を fitted midpoint に置き換え,根拠のコメントを書いた.fixtures の両側の余白が広い 8 規則には inconclusive:(blind の理由)を書いた.
  • fix(lint): address review findings deferred from the #74 migration PRs #196 の指摘への対応:
    • json-parse-uses-model-validate-json:callee(function が model_validate で終わる attribute)で照合する.Response(Order.model_validate(data)) の外側の呼び出しは subject にならない.
    • fixture-justified:「軽量なら」「helper で足りるなら」「scope が広すぎるなら」を「2 件未満」の分岐の中にまとめた.2 件以上ならどんな場合も違反ではない.
    • frozen-model-subclass-keeps-locked-settings:文脈の広さは located のままとした.graph arm はソースを渡さず,同じファイルの記号しか載らないため,別ファイルの基底をたどる問題は解決しない.同じファイル内の継承の連鎖と,FrozenBaseModel を直接 import する子クラスは判定できる.別ファイルの中間クラスを経由する子孫は判定できないので,Limits に記録した.
  • 分離しなかった規則の書き直し(理由は「規則ごとの結果」の表を参照):
    • import-name-self-explanatory:state を local から located にした(名前の衝突や呼び出し箇所は import の外にあるため).criteria に「パスが 1〜2 部分」「3 部分以上は長い」「慣例でない 1〜2 文字の alias」という基準を書いた.
    • no-exposed-mutable-collection:state を located にした(返す field が tuple か,クラスが不変条件を守るかは __init__ とクラス定義にあり,local では見えない).
    • frozen-model-subclass-keeps-locked-settings:基底の値を明記し,同じ値を繰り返すだけ(strict=True)なら違反ではないと書いた.
  • import-name-self-explanatory の expect.yml を window: 0 にした.1 行ずつ並ぶ import では window: 1 のラベルが隣の行にも及び,bad が優先されて clean が bad として数えられていた.
  • .ignore(新規)と pyproject.toml の [tool.deptry] extend_exclude:fixtures に植えた違反(BaseModel の直接継承,slots なしの dataclass,架空のパッケージの import)を,CI の ast-grep と deptry が報告しないようにする.ruff,ty,vulture には同じ除外がすでにある.
  • tests/hooks/test_model_rules_tiers.py:baseline を持つ規則が先に cap を使う tier になるので,function-single-purpose を「未調整」と仮定していたテストを,全言語に baseline が揃って 1 tier になっても壊れない形に変えた.

規則ごとの結果

jev-lint eval --replay(baseline は 2026-11-18,3 passes,平均値).「最高 clean」「最低 bad」は fixture の平均値.

規則 bad / clean 0.5 での tp / fp / fn 最高 clean 最低 bad 新 cutoff 判定
command-query-naming 8 / 8 8 / 0 / 0(0.76) 0.58 0.92 0.78 分離
construction-placement-by-purity 5 / 5 5 / 0 / 0 0.41 0.91 0.68 分離
construction-separate-from-execution 4 / 4 4 / 1 / 0 0.67 0.92 0.81 分離(fit で fp 解消)
error-message-names-operation 4 / 5 4 / 0 / 0 0.20 0.95 0.61 分離,blind
fixed-choices-use-enum 4 / 5 4 / 0 / 0 0.08 0.92 0.5 分離,blind
fixture-justified 4 / 4 4 / 0 / 0 0.13 0.94 0.54 分離,blind
frozen-base-model-sets-all-settings 5 / 4 5 / 0 / 0 0.04 0.95 0.5 分離,blind
frozen-model-subclass-keeps-locked-settings 4 / 5 4 / 1 / 0 → 4 / 0 / 0 0.56 → 0.06 0.89 → 0.94 0.5 書き直しで分離,blind
function-single-purpose 3 / 4 3 / 0 / 0 0.48 0.76 0.62 分離
import-name-self-explanatory 5 / 5 4 / 1 / 1 → 5 / 0 / 0 0.53 → 0.30 0.46 → 0.82 0.57 書き直しで分離,blind
json-parse-uses-model-validate-json 3 / 5 3 / 0 / 0 0.25 0.94 0.62 分離,blind
known-defect-marker-names-removal 4 / 4 4 / 0 / 0 0.24 0.80 0.52 分離,blind
no-comment-restating-code 3 / 5 3 / 0 / 0 0.30 0.86 0.59 分離,blind
no-exposed-mutable-collection 3 / 5 3 / 2 / 0 → 3 / 1 / 0 0.86 → 0.93 0.80 → 0.96 0.5(据え置き) 書き直し後も分離しない(advisory のまま)
no-reaching-through-collaborators 4 / 3 4 / 2 / 0 0.73 0.84 0.79 分離(余白は狭い)
plain-class-defines-slots 3 / 5 3 / 2 / 0 0.77 0.97 0.89 分離(fit で fp 解消)
repeated-tests-use-parametrize 3 / 3 3 / 1 / 0 0.50 0.78 0.66 分離(fit で fp 解消)
string-literal-is-named-constant 4 / 3 4 / 0 / 0 0.25 0.66 0.47 分離
value-object-is-immutable 4 / 5 4 / 0 / 0 0.15 0.89 0.53 分離,blind

書き直した 3 規則は,ユーザーが 1 回だけ再 eval(--accept)した結果で書いている(矢印の右側).これ以上の再実行はしない方針なので,分離しない規則は advisory のまま限界を記録する.

昇格の候補(この回では昇格しない)

ADR-0021 の昇格条件は「fixtures で偽陽性 0」と「リポジトリ自身のファイルで偽陽性 0」の両方を満たすことである.後者はキーが必要なため測っていない.下表は前者を満たし,余白が pass ごとのばらつきより広い規則である.リポジトリ全体での実行で偽陽性 0 を確かめてから昇格させたい.

規則 昇格すると消せる文章
command-query-naming AGENTS.md「name command functions for their side effects and query functions for the value they return」
function-single-purpose AGENTS.md「Keep functions single-purpose at one abstraction level」の部分(「with short variable lifetimes」は残す);python-style code_style.md「Keep functions focused and small」
no-comment-restating-code AGENTS.md「Minimize comments and docstrings」の文のうち,コードを言い換えるコメントの部分(公開 API の docstring を求める部分は残す)
construction-placement-by-purity models.md「Use classmethods as alternative constructors for pure construction ...」とその例
fixed-choices-use-enum models.md「Use Enum/StrEnum for fixed choices instead of raw string literals or dict maps」
fixture-justified testing.md の @pytest.fixture と「Helper function」の 2 行(「Fixture scope」の行は 2 件以上で使われる fixture を規則が判定しないため残す)
frozen-base-model-sets-all-settings なし(models.md の FrozenBaseModel の例は書き方の手本として残す)
json-parse-uses-model-validate-json models.md「Parse JSON with Model.model_validate_json(...)」
known-defect-marker-names-removal testing.md「and a comment naming the condition for removing the marker」の部分
string-literal-is-named-constant code_style.md「define semantically meaningful string literals as module-level constants ...」の部分
value-object-is-immutable models.md「Use @dataclass(frozen=True, slots=True) for internal value objects」のうち frozen の部分(slots=True は残す)
error-message-names-operation なし(python-style に対応する文章がない)

候補にしない規則:

  • construction-separate-from-execution,no-reaching-through-collaborators,plain-class-defines-slots,repeated-tests-use-parametrize:0.5 では偽陽性があり,fit 後も clean との余白が 0.1〜0.15 しかない.
  • no-exposed-mutable-collection:書き直し後も分離しない(最高 clean 0.93,最低 bad 0.96).
  • import-name-self-explanatory,frozen-model-subclass-keeps-locked-settings:書き直しで分離したが,書き直し後の eval が 1 回だけなので,次の回で確かめる.

昇格したときに AGENTS.md から消せる文(親セッションが全レーン完了後に扱う):「name command functions for their side effects and query functions for the value they return」,「Keep functions single-purpose at one abstraction level」(前半),「Minimize comments and docstrings」(コードを言い換えるコメントの部分).ただし AGENTS.md は全言語共通なので,他言語の同じ規則も昇格したときにだけ消せる.

Stop 1 回あたりの subject 数と費用

jev-lint review --dry-run(この branch の規則,fixtures は除外)を,マージ済み PR の状態を再現した一時 clone で実行した.

PR Python 規則 全規則 費用見積り(全規則)
#201(Python 33 ファイル,+4120 行) 984 988 約 $0.028
#203(23 ファイル,+2305 行) 774 776 約 $0.021
#224(5 ファイル,+80 行) 38 38 約 $0.001

#201 で多いのは command-query-naming(246),function-single-purpose(246),string-literal-is-named-constant(156),fixed-choices-use-enum(139),no-comment-restating-code(115).SUBJECT_CAP = 250 は「最大のセッションで 104」という測定を根拠にしている.規則の追加後は大きな PR がこの cap を大きく超え,後ろの tier とファイルが切られる.費用は 1000 subject でも約 $0.03 で問題にならない.したがって cap を見直すかどうかは所要時間で判断すべきだが,所要時間はキーなしでは測れない(hook のコードはこのレーンの範囲外).

eval の費用

1 回の全 eval(19 規則,3 passes,132 requests):baseline の spent の合計で約 $0.011.dry-run の見積りは約 $0.010.書き直した 3 規則の再 eval:約 $0.0016(12 requests).

Limits

  • no-exposed-mutable-collection は,private な list field を持つ不変条件のない dataclass(CsvRow)を違反と判定する(0.93).文脈を located に広げても分離しなかった.cutoff は 0.5 のままで advisory.baseline があるため rule_tiers() の tuned tier に入り,subject cap を先に使う.baseline を外すと test_every_saved_eval_baseline_still_scores_as_accepted が「baseline なし」で失敗するので外していない(review 指摘,Limits として記録).
  • .ignore は ast-grep のほかに ripgrep なども読むため,それらの検索で fixtures が出なくなる.
  • fixtures は規則ごとに 6〜10 件と少なく,著者がラベルを付けたもので,較正とは言えない.blind の 8 規則は境界の fixture がない.
  • frozen-model-subclass-keeps-locked-settings は,別ファイルの中間クラスを経由する FrozenBaseModel の子孫を判定できない(file 軸の制約).
  • construction-separate-from-execution の main()(build_order_service を呼ぶだけ)は matcher に選ばれないので,fixture に置いたが subject ではない.
  • ローカルの tests/hooks で test_cleanup_worktrees_isolation.py::test_a_gitlink_worktree_is_skipped_without_running_submodule_git が失敗する.sandbox 内で submodule の git clone ができないためで,この変更とは関係ない(CI で確認する).

Refs #220
Refs #196

🤖 Generated with Claude Code

furedea and others added 2 commits November 18, 2026 15:30
Label violating and conforming cases for every Python jev-lint rule that had
none, so each rule can be measured with jev-lint eval. Apply the #196 notes:
match json-parse-uses-model-validate-json on the callee, and keep every
lightweight or helper condition of fixture-justified inside the fewer-than-two
branch.

Refs #220

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the provisional 0.5 cutoffs with jev-lint's fitted midpoints and
record each basis next to the threshold. Declare inconclusive for the suites
whose fixtures sit far from the cutoff on both sides. Send the whole file to
import-name-self-explanatory and no-exposed-mutable-collection, whose
evidence lies outside the matched node, and state that repeating a base value
is not a violation in frozen-model-subclass-keeps-locked-settings. All rules
stay advisory.

Refs #220

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 18, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 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-18T07:26:47.899712Z d805d8b 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.

Scope: I read the changed rule.yml files and tests/hooks/test_model_rules_tiers.py in full. I did not read the fixtures, expect.yml files or baseline.json files, which make up most of the 94 files. I could not run the test suite here because the sandbox denied it, so none of this is verified by a test run.

  • All 19 Python rule folders have a baseline.json, so rule_tiers returns one tier covering the Python rules. The relaxed assertion in test_the_shipped_python_rules_are_tuned_and_claim_the_cap_first accepts that shape, and still catches a regression where those rules lose their baselines.
  • The json-parse-uses-model-validate-json rule now matches on the callee, so Response(Order.model_validate(data)) no longer makes the outer call a subject. The fixture-justified criteria now put the lightweight, helper and scope conditions inside the "fewer than two tests" branch.
  • P3, optional: frozen-model-subclass-keeps-locked-settings, import-name-self-explanatory and no-exposed-mutable-collection keep threshold: 0.5. Unlike the other rules, they have no comment saying the cutoff was fitted. If 0.5 is still the placeholder for these three, a short comment saying so would stop a later reader taking it for a fitted value.

@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: 290de4b937

ℹ️ 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 fixtures plant code that the static rules and deptry report. ast-grep
honours .ignore when CI scans the tree; deptry gets an explicit exclusion,
as ruff, ty and vulture already have.

Refs #220

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 18, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary (read-only): no blocking findings, so I posted no inline comments.

What I checked:

  • All 19 Python rules have a baseline.json, an expect.yml and a fixtures/ directory. Each expect.yml has 6–16 labelled entries.
  • The new fixtures carry no Bad/Clean label comments. The only ones that do are command-query-naming and error-message-names-operation, which already existed before this PR.
  • The .ignore, deptry, vulture, ruff and ty exclusions all use the same model-rules/*/*/fixtures glob.
  • The three fix(lint): address review findings deferred from the #74 migration PRs #196 rule rewrites (json-parse-uses-model-validate-json, fixture-justified, frozen-model-subclass-keeps-locked-settings) match the PR description.

Observations, none blocking:

  • P3: test_the_shipped_python_rules_are_tuned_and_claim_the_cap_first passes if first == (REAL_RULES,). That is also the case once every language has baselines, so the second branch is only exercised today. This is fine as written, but the assertion is loose.
  • P3: Every baseline.json records "at": 0.5 and "cutoffs": {}, while rule.yml now carries fitted thresholds (e.g. 0.62, 0.54). I couldn't run jev-lint in this environment to confirm that eval accepts the baselines against the new thresholds. A jev-lint eval run in CI would confirm it.
  • P3: The json-parse comment says the cutoff 0.62 is the fitted midpoint of 0.25 and 0.94, which would be about 0.60. The fit uses mean scores over 3 passes, so this may only be rounding in how it was fitted.

I could not run the test suite or jev-lint here, so none of this has been executed.

@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: b7ce4eb225

ℹ️ 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 tests/hooks/test_model_rules_tiers.py Resolved
Accept the re-run eval of import-name-self-explanatory,
no-exposed-mutable-collection and frozen-model-subclass-keeps-locked-settings.
The first and last now separate and get their fitted cutoffs, declared blind;
no-exposed-mutable-collection still does not separate, keeps 0.5 and stays
advisory with the reason beside its cutoff.

Refs #220

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 18, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

Read-only review of the rule metadata changes. I checked rule.yml for json-parse-uses-model-validate-json and fixture-justified in detail, plus .ignore and the pyproject.toml deptry exclude. I did not read the other 17 rule.yml diffs or the fixture files, and I did not run jev-lint eval.

Findings

  • P2 — The 19 last.json files are committed. For fixture-justified I confirmed with diff that it matches baseline.json byte for byte; I did not compare the other 18. Nothing in docs/, tests/ or .gitignore refers to last.json. They look like raw run output and add about 5,000 lines. I suggest dropping them and gitignoring the pattern.

Observations, not findings

  • baseline.json for fixture-justified records "at": 0.5, but rule.yml now has threshold: 0.54. I couldn't tell whether the draft hash covers the threshold or comments, so I can't say whether a hash check would flag the baselines as stale. Re-running jev-lint eval after the final edits would settle it.
  • The json-parse-uses-model-validate-json callee match and the fixture-justified criteria rewrite look consistent with the description.

No P0 or P1 issues found.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 6f4055b641

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

Drop the last.json files that jev-lint eval writes beside each baseline and
ignore them. Assert that every Python model rule, not two of them, claims the
subject cap first.

Refs #220

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@furedea

furedea commented Nov 18, 2026

Copy link
Copy Markdown
Owner

@codex review

@github-actions

Copy link
Copy Markdown

Review summary

I found nothing at P0–P2, so there are no inline comments.

What I checked

  • json-parse-uses-model-validate-json matcher: the callee-based matcher (kind: call with has: field: function, kind: attribute, attribute ^model_validate$) fixes the fix(lint): address review findings deferred from the #74 migration PRs #196 wrapping-call case. Response(Order.model_validate(x)) no longer makes the outer call a subject. model_validate_json is still not matched.
  • Config files: the pyproject.toml deptry extend_exclude regex, the .ignore glob and the .gitignore last.json pattern all match the agents/hooks/lint/model-rules/<lang>/<rule>/fixtures layout.
  • rule_tiers test: I checked the rewritten test in tests/hooks/test_model_rules_tiers.py against rule_tiers in model_rules_gate.py. Both branches of its or hold: one tier of folders when ADR rules exist, or the whole directory when none do. The test stays valid once every language has baselines.

Notes, not blocking

  • P3, baselines vs. thresholds: every baseline.json records "at": 0.5, "cutoffs": {} and a draft hash. The new threshold: values in rule.yml were fitted from those baselines afterwards. jev-lint isn't in this repo, so I couldn't check whether eval --replay or the gate flags the baselines as stale against the edited rule.yml. Running jev-lint eval --replay once on the merged tree would settle it.
  • P3, subject cap: with all 19 Python rules now in the "tuned" tier, they claim SUBJECT_CAP = 250 before any untuned rules. The PR description already measures 984 subjects on feat(hooks): judge gh calls by effect through a policy table #201, so on large PRs the untuned (non-Python) rules and later files will be dropped. That was disclosed and is out of scope here.
  • P3, .ignore: it also hides the fixtures from ripgrep-based search, including the agent Grep tool. The PR lists this under Limits.

Fixtures and expect.yml labels are author-assigned and there are only 6–10 per rule. The PR says so, and 8 rules are marked inconclusive. I did not review them individually.

I did not run the evals or the test suite. The review was read-only.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: d805d8bce2

ℹ️ 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 f409adb into main Nov 19, 2026
29 checks passed
@furedea
furedea deleted the feat/fit-jev-rules-python branch November 19, 2026 02:57
furedea-agent Bot pushed a commit that referenced this pull request Nov 19, 2026
… run

With the rules fitted in #240-#244, #201 alone plans 988 subjects, far
over the cap of 250. One uncached run of that diff sent all 60 planned
requests, answered every subject and took 3.41 s through op (0.97 s of
asking) for 0.025 USD, so 2000 holds twice it within the 90 s budget
and jev-lint's token burst. The ADR now also states the run's real time
limits: 90 s of the Stop and 60 s per child.

Refs #220

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
furedea added a commit that referenced this pull request Nov 19, 2026
## 概要

#220 の Rust 分.Rust の jev-lint 規則 14 件すべてに eval の fixtures と baseline
を揃え,cutoff を jev-lint の fitted midpoint に置き換えた.分離しなかった規則は ask / criteria
を書き直した.規則はすべて advisory のままで(ADR-0027),style skill の文章も消していない.

## 変更

- fixtures がなかった 11 規則に
`fixtures/violating.rs`・`fixtures/conforming.rs`(clean は criteria の
false 側に寄せた境界例)と `expect.yml` を追加した.
- `no-reaching-through-collaborators`:matcher の `$A.$B.$C.$D($$$)`
はフィールドの連鎖しか選ばず,`self.session.connection().pool().acquire()`
のようなメソッド連鎖の違反例 5 件をどれも選んでいなかった.中間がメソッド呼び出しの 3 形も選ぶよう広げた(#196 の「matcher
は広め」).agent-harness の大型 PR では subject が 30〜55 件増える.
- 1 回目の eval で分離しなかった 5 規則の criteria
を書き直した:`construction-separate-from-execution`(composition root
を誤検出していた,0.89),`no-exposed-mutable-collection`(clean 4
件すべてを誤検出していた,0.69〜0.96;struct 定義が見えるよう `state: located`
に変更),`serde-types-follow-config-conventions`(命名の混在を見逃していた,0.19),`domain-states-are-enums`,`filesystem-code-keeps-paths-and-symlinks-safe`(gap
が狭かった).
- Rust の criteria だけを変えた 2 規則(`construction-…`,`no-exposed-…`)は,jev-lint
の drift 警告に従い `divergent:` で理由を宣言した.
- 各 `rule.yml` に cutoff の根拠(ケース数,clean の最高値,violation の最低値,baseline
の日付)をコメントで書いた.
- `tests/test_model_rule_files.py`:main の `SUITE_RULE_IDS` で Rust も Go
と同じく全規則(`None`)に eval スイートを求める.
- `tests/test_agents_md_model_rules.py`:この PR で全 74 規則に baseline
が揃い,実ディレクトリでは tier が 1 つになる.「tier に分けても subject
が減らない」というテストが自分自身と比べるだけになるので,一時コピーで Python の baseline を外して 2 tier
を作るようにした.
- 1 回目の eval でできた `last.json` を誤ってコミットしていたので,消した.

## cutoff の fit

baseline は 2026-11-18,3 passes.値は 3 passes を通じた最高・最低.tp / fp / fn は新しい
cutoff での値で,保存した baseline から `jev-lint eval --replay
agents/hooks/lint/model-rules/rust` で求めた(モデル呼び出しなし).

| 規則 | bad / clean | clean の最高 | bad の最低 | cutoff(旧 → 新) | tp / fp / fn
| 備考 |
| --- | --- | --- | --- | --- | --- | --- |
| `command-query-naming` | 4 / 6 | 0.53 | 0.84 | 0.68 → 0.69 | 4 / 0 / 0
| |
| `construction-separate-from-execution` | 5 / 5 | 0.36 | 0.88 | 0.5 →
0.62 | 5 / 0 / 0 | blind |
| `conversion-and-query-names-follow-rust-convention` | 6 / 7 | 0.10 |
0.46 | 0.5 → 0.28 | 6 / 0 / 0 | 0.5 では violating.rs:29 を 3 pass 中 2
回見逃していた |
| `domain-states-are-enums` | 5 / 5 | 0.27 | 0.88 | 0.5 → 0.57 | 5 / 0 /
0 | blind |
| `error-message-names-operation` | 8 / 7 | 0.15 | 0.56 | 0.5 → 0.36 | 8
/ 0 / 0 | |
| `filesystem-code-keeps-paths-and-symlinks-safe` | 4 / 6 | 0.20 | 0.85
| 0.5 → 0.53 | 4 / 0 / 0 | blind |
| `function-single-purpose` | 4 / 5 | 0.25 | 0.71 | 0.5 → 0.48 | 4 / 0 /
0 | |
| `known-defect-marker-names-removal` | 6 / 5 | 0.16 | 0.58 | 0.36 →
0.37 | 6 / 0 / 0 | |
| `no-comment-restating-code` | 5 / 5 | 0.22 | 0.93 | 0.5 → 0.58 | 5 / 0
/ 0 | blind |
| `no-exposed-mutable-collection` | 4 / 4 | 0.06 | 0.96 | 0.5 → 0.51 | 4
/ 0 / 0 | blind |
| `no-reaching-through-collaborators` | 5 / 5 | 0.46 | 0.78 | 0.5 → 0.62
| 5 / 0 / 0 | |
| `paths-are-joined-not-formatted` | 5 / 5 | 0.14 | 0.96 | 0.5 → 0.55 |
5 / 0 / 0 | blind |
| `public-types-protect-invariants` | 5 / 5 | 0.24 | 0.83 | 0.5 → 0.53 |
5 / 0 / 0 | blind |
| `serde-types-follow-config-conventions` | 4 / 5 | 0.18 | 0.24 | 0.5 →
0.21 | 4 / 0 / 0 | unstable |

「blind」は fixtures が境界から遠すぎて劣化を検出できないという replay の判定で,「unstable」は最も弱い違反の
pass ごとの揺れが cutoff との余白より大きいという判定.どちらも各 `rule.yml` に `inconclusive:`
で理由を宣言した.

## 昇格しない

ADR-0027(#250)により,model-judged の規則は gate(`severity: error`)にせず,すべて
advisory のままにする.この PR でもどの規則も昇格しておらず,昇格の計画もない.規則の文章は `AGENTS.md` と style
skill に残す.

## Stop あたりの subject 数と費用

agent-harness(Rust)の直近 60 PR を `jev-lint review --dry-run` で数えた(キー不要).

- Rust 規則だけの subject 数は中央値 6,p90 219,最大 667.
- #246 で上限(`SUBJECT_CAP`)が 250 から 2000 に上がる(数値は #246 の PR 本文による.この PR
ではコードを変えていない).2000 では 60 PR のどれも上限を超えず,最大の 667 でも約 3 分の 1 に収まる.250
のままなら超えていたのは 4 件で,どれも大型のリファクタ PR だった(main の規則だけでも 612,596,571,406).
- 1 subject あたり約 0.000025 USD なので,最大の 667 subject で約 0.017 USD,上限いっぱいの
2000 で約 0.05 USD.60 PR 分の合計は 0.12 USD.
- 1 回の Stop は 1 PR より小さいことが多いので,Rust 規則を足しても上限 2000 で足りると考える.

## 検証

- `jev-lint eval --replay agents/hooks/lint/model-rules`:74 suite(s),
all as shipped(origin/main 1721d17 に rebase 後).
- `jev-lint rules --no-config -R agents/hooks/lint/model-rules`:74
rule(s) loaded, 0 error(s).Rust の drift 警告なし.
- `uv run pytest`:rebase
後に全件実行し,`test_the_tiers_together_plan_the_same_subjects_as_the_whole_directory`
の 1 件が上記の理由で落ちたので直した.直した後,`tests/test_model_rule_files.py` と
`tests/test_agents_md_model_rules.py` は 19 passed.
- モデル呼び出しの費用(ユーザーが実行,キーは guard によりエージェントから使えない):1 回目の eval(11
suites)0.0069 USD,gaps 0.0078 USD,`eval --accept`(14 suites)約 0.0089
USD.合計約 0.024 USD.

## Limits

- fixtures は規則ごとに 8〜15 件で,較正とは言えない.blind の 8 規則には境界の fixture がない.
- `gaps` を全 Rust fixtures にかけると(criteria を書き直す前),`command-query-naming`
と `error-message-names-operation` で,他の規則の fixtures に cutoff の直下(余白
0.01,0.04)の subject があった.
- #196 の 2 コメントには Rust の項目がなかった.
- `docs/DESIGN.md` の「Five cutoffs are fitted
…」の段落は古くなった.全言語で共有している文書なので,全レーンが終わった後に親で更新してほしい.
- 計画からの逸脱:なし(昇格しないことは ADR-0027 の決定どおり).
- rebase(#240,#242,#243,#244,#250 などの後)の衝突は
`tests/test_model_rule_files.py` の 1 か所で,main の `SUITE_RULE_IDS`
に寄せて解消した.cutoff と baseline は変えていない.

Refs #220

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

---------

Co-authored-by: furedea <132188853+furedea@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
furedea added a commit that referenced this pull request Nov 19, 2026
…s under it (#246)

Stop 時の model rules の subject 上限 `SUBJECT_CAP` を,実測に基づいて 250 → 2000
に上げます.
あわせて,cap が効くときにキャッシュ済みファイルの finding が落ちる不具合と,1 ファイルも cap
に入らないと差分全体を送ってしまう不具合を直します.
当初含めていた「promote 済み rule(`severity: error`)で毎 Stop ブロックする
gate」は,ADR-0027(#250)の決定に従って取り除きました.

Refs #220

| 項目 | 変更前 | 変更後 |
| ---------------------------------------------------------------------
| ----------------------------------------------- |
-------------------------------------------------------------------------------------------
|
| `SUBJECT_CAP` | 250 | 2000 |
| cap で他のファイルが外れるとき,全 subject がキャッシュ済みのファイル | judge から外れ,キャッシュ済み finding
が消える | 費用 0 として必ず渡し,finding を報告する |
| 1 ファイルも cap に入らず,一部がキャッシュ済み | 選択が空になり差分全体を送る(cap 超過) | 何も送らない(`0/N
subjects` と報告) |
| ADR-0021 の実行時間の記述 | 「A run has 60 seconds」 | Stop 内で最大 90
s(検証の使用分を差し引く),子プロセスごとに最大 60 s(planning は 20 s) |

## 検証

- [x] `uv run pytest`(全体): 6134 passed, 2 skipped(origin/main にリベース後)
- [x] ruff check / ty: pass.lefthook pre-commit / commitlint: pass
- [x] Red → Green: 全件キャッシュ済みファイルのテストは,実装前に「差分全体を送る」理由で失敗
- [x] Red → Green: 1 ファイルも cap に入らない場合のテストは,実装前に `op` が呼ばれて失敗
- [x] Red → Green:
`test_the_subject_cap_holds_the_largest_measured_session_whole` を 988
subjects に更新すると,250 で失敗
- [x] CI: push 後の結果は下のチェック欄を参照

## 計測(`SUBJECT_CAP` の根拠)

- 条件:2026-11-18,`jev-lint` 0.7.0,model `jev-1.14.0`.#201 のマージコミット
`db7226d0` を `--base 746cd48` で review.`-R
agents/hooks/lint/model-rules`(#240–#244 後の全ルール,ADR
ルールを含む),新規キャッシュ,concurrency は既定の 32,`op run` 経由
- 計画(dry-run): 988 subjects,60 requests,cached 0,約 $0.028
- 実測(**1 回のみ**のためばらつきは不明): real 3.41 s(user 2.70 s,sys 0.18 s),exit 0
- 記録ファイル(`--record`)との照合:送信は 60 requests で計画どおり.988 subjects
すべてに回答があり(欠落 0),retried・rateLimited・splits はいずれも 0.問い合わせ区間の `wallMs` は
969 ms(リクエスト時間の合計は 20.2 s),入力 583,810 tokens,$0.0245
- 参考:同じ差分を全件キャッシュ済みで実行すると(ネットワークなし),3 回とも 0.17–0.18 s
- 判断:2000 は #201 の 2 倍超を丸ごと収める.1 subject ≈ 590 tokens なので,cap いっぱいでは
jev-lint の token burst(1.2M)の約 98% になり,超過分のペーシングは最大でも約 6 s.実測の 10 倍でも 90
s 予算の 70%(63 s)を大きく下回る.計測が 1 回だけなので,数値そのものではなく余裕幅で判断した

<details>
<summary>範囲・除外・経緯</summary>

-
範囲:`agents/hooks/lib/model_rules_run.py`(`SUBJECT_CAP`,`_capped_plan`),ADR-0021
の amendment(cap と実行時間の記述),`docs/DESIGN.md` と `docs/DESIGN_ja.md`(cap
の値と根拠),テスト(`test_model_rules.py`,`test_model_rules_report.py`,`test_model_rules_tiers.py`)
- 取り除いたもの(ADR-0027): exit 1 を error finding の結果として読む処理,gating finding
による毎 Stop ブロック,その文言・receipt・resume
項目,`test_model_rules_gate_findings.py`,ADR-0021 への gate の追記.revert コミット
676f15e で取り除き,squash 後の差分には残らない
- 除外(ブリーフに従う): model rule の promote やブロック(ADR-0027),セッションごと 1
回の報告(#245/#252),ルールファイルと cutoff,他リポジトリ
- キャッシュと cap: dry-run の batches は未キャッシュの subject だけを含むため,キャッシュ済み subject
はもともと cap に数えられていなかった(変更不要)
- batch の `file` と渡したパスの一致:実際の dry-run(#201 の差分,34
ファイル)で,全件完全一致することを確認した
- #252 との関係:#252 は `model_rules_gate.py` を変更する.本 PR は同ファイルを変更しないため,競合はない
- レビュー対応(rework 後の 1 回目):
- P1(Claude)「gate 機能が差分にない」: 説明を差し替える前のレビューだった.gate は ADR-0027
に従って意図的に除いたもので,タイトルと本文は絞り込み済みと返信して resolve
  - P2(Codex)「設計書が 250 のまま」: 5891a33 で両方の設計書を 2000 と新しい根拠に更新
- P3(Claude summary,スレッドなし)「`paths` が空のレビューでは全件キャッシュ済みファイルが残らない」:
`_Changes.reviews` は `sendable` が空でないときだけ `Review`
を作り,常に明示的なパスを渡すため,現状では起きない(潜在のみ).修正はせず,ここに記録する
- レビュー対応(rework 後の 2 回目,修正なし): P2「対象のないパスがあると `if not chosen`
を通らず,対象のないファイルだけで `op run` が起動する.`judged` にもスキップ分のキャッシュが混ざる」.dry-run
だけでは対象のないファイルと全件キャッシュ済みのファイルを区別できず,後者のキャッシュ済み finding
を報告するにはその起動が必要.新たな問い合わせは 0 で,誤った finding も出ない.件数表示のずれは以前からのもので advisory
に限られるため,ブリーフの基準に従い返信・resolve・記録にとどめた(Limits)
- 前回レビューの P3「never paced に余裕がない」は,コメントと ADR の表現を「最大約 6 s のペーシング」に直して解消した

</details>

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

---------

Co-authored-by: furedea <132188853+furedea@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
furedea added a commit that referenced this pull request Nov 20, 2026
…258)

## 概要

#196 の Python 項目(#192 の後続,`py_*` 規則,Python の model rule,#191 の Python
部分)を origin/main で確かめた.ast-grep の項目は #192・#216・#240 で対応済みか obsolete
だった.残っていた Python の model rule の selector 3 件を広げた(#196 の方針どおり matcher
は広く取り,判定は criteria に任せる).どの規則も advisory のままで,昇格も文章の削除もしていない(ADR-0027).

Refs #196

## 変更

- `no-reaching-through-collaborators`:呼び出しで終わらないプロパティ参照の連鎖(`return
order.customer.address.city`)も選ぶ.selector を `$A.$B.$C.$D($$$)` から
`$A.$B.$C.$D` にした(呼び出しの連鎖も含む).
- `no-exposed-mutable-collection`:公開名のフィールドをそのまま返す関数(`return
self.items`)も選ぶ.`return len(self.items)` のような計算結果は選ばない.
- `no-comment-restating-code`:関数の直前(デコレータの上を含む)にある,tool directive
でないコメントも選ぶ.規則は `axis: file` なのでモデルにはファイル全体が渡り,直前のコメントも見える.
- 3 規則の fixtures に新しい形の bad(とコメント規則の clean 1 件)を足し,`expect.yml` に label
を足した.既存の行番号は動かしていない.
- `tests/test_python_model_rules.py`:3 件の selector テストを追加(Red は 3 件とも
subject 0 で確認).
- `tests/test_agents_md_model_rules.py`:Python の共通サンプルで `label`(`return
self.text`)が新たに選ばれるので期待値を 2 にした.

## 項目ごとの状態

| 項目 | 状態 | 根拠 |
|
--------------------------------------------------------------------------------------------
| ------------------ |
-----------------------------------------------------------------------------------------------------------------
|
| `string-literal-is-named-constant`:`parent:` が ast-grep のキーでない | 対応済み
| 現在の規則に `parent:` は無い(#216 で obsolete と整理) |
| `py_definition_order`:`ColorMixin[T]` を Enum 扱い | obsolete | 規則は #192
で削除 |
| `py_async_test_anyio_marker`(部分一致,fixture 経由,別名 receiver,`anyio_mode =
"auto"`) | obsolete | 規則は #192 で削除(ADR-0021) |
| `py_plain_class_slots`(アンパック代入,`__dict__`,`class User()` / `(object)`)
| obsolete | jev-lint `plain-class-defines-slots` へ降格(#192) |
| `py_pydantic_validate_json`(初期化,`json` の束縛,複数名 import の別名) | obsolete
| jev-lint `json-parse-uses-model-validate-json` へ降格(#192) |
| `py_frozen_base_model_config`:`model_config` の再代入 | obsolete |
規則は削除,jev-lint `frozen-base-model-sets-all-settings` へ(#192) |
| `py_frozen_base_model_no_override`:`ConfigDict(**{...})` | obsolete |
規則は削除,jev-lint `frozen-model-subclass-keeps-locked-settings` へ(#192) |
| `py_pydantic_base_model_only_in_frozen_base`:`pydantic.v1` | 対応済み |
#216(`from pydantic.v1 import BaseModel` と `pydantic.v1.BaseModel` を
invalid に追加済み.別名は規則の Limits) |
| `py_no_pytest_asyncio`:別名 `pytest` 経由のマーカー | 対応済み(Limits) | #216 で規則の
`Limits:` に記録(バインド解析が要る.ADR-0021 の方針で demote しない) |
| `py_dataclass_slots` | 対応済み | #192 本文の後続項目(`cached_property` の別名)は
#192 内で修正済み.#196 に未解決の個別項目は無い |
| `fixture-justified`:基準の衝突 | 対応済み | #240 |
| `json-parse-uses-model-validate-json`:callee で照合 | 対応済み | #240 |
| `frozen-model-subclass-keeps-locked-settings`:別ファイルの基底 | 対応済み(Limits)
| #240(`located` のまま,別ファイルの中間クラスは Limits) |
| `no-comment-restating-code`:Python の docstring | 対応済み | 現在の selector に
docstring の分岐がある(`tests/test_agents_md_model_rules.py` の `documented`) |
| `no-comment-restating-code`:関数直前のコメント(Python 分) | 修正 | この PR |
| `no-exposed-mutable-collection`:Python 公開名のフィールド | 修正 | この PR |
| `no-reaching-through-collaborators`:プロパティ参照の連鎖(Python 分) | 修正 | この PR
|
| ローカルで失敗していた
`test_python_style_model_rules_select_the_subjects_they_ask_about` |
対応済み | origin/main ではローカルでも通る(rebase 後に確認) |

## baseline の再取得と cutoff

matcher を変えた 3 suite の baseline は,ユーザーが `jev-lint eval --accept`
で取り直した(2026-11-19T12:18Z,3 passes).cutoff
と根拠のコメントをその値に合わせた(a70d16d5).問い(ask / criteria)はその後変えていない.

| 規則 | cutoff | 結果(3 passes の平均) |
| --- | --- | --- |
| `no-reaching-through-collaborators` | 0.79(据え置き) | 呼び出しで終わる違反は最低
0.87,clean は最高 0.72.プロパティ連鎖の bad(subjects.py:48)は 0.68 で FN |
| `no-exposed-mutable-collection` | 0.5(据え置き) | 公開フィールドの
bad(subjects.py:95)は 0.96 で検出.従来からの FP(CsvRow,subjects.py:80)は 0.94 |
| `no-comment-restating-code` | 0.59 → 0.62 | clean は最高 0.37(公開
docstring),関数内の違反は最低 0.87.関数直前コメントの bad(subjects.py:61)は 0.11 で FN.古くなった
`inconclusive:` を削除 |

## Limits

-
`no-reaching-through-collaborators`:呼び出しで終わらないプロパティ連鎖は選ぶようになったが,fixture
では 0.68(clean の 0.67 と 0.72 の間)で,どの cutoff でも分離しない.今は見逃す(FN).
- `no-comment-restating-code`:関数直前のコメントは選ぶようになったが,fixture の言い換えコメントは
0.11 で見逃す(FN).また `follows` は直前の兄弟コメントを何でも選ぶので,前の文の行末コメント(`TIMEOUT = 5 #
seconds`),空行を挟んだ区切りコメント,複数行コメントの最終行だけを directive 判定する場合にも subject
が増える(余分な問い合わせ.2 回目のレビュー指摘).
- `no-exposed-mutable-collection`:公開フィールドの getter(`return
self.name`)をすべて選ぶので subject が増える(#196 の方針で matcher は広く取る).`return
(self.items)` のように括弧で包む書き方は選ばない(見逃し.2 回目のレビュー指摘).CsvRow の
FP(0.94)は従来どおり残る.

## レビュー対応

- 1 回目:`no-comment-restating-code` の ask を「in this function, or just
above it」に合わせた.関数直前コメントの bad fixture を非公開 helper にした(7ab1c139).baseline
は上のとおり再取得した.
- 2 回目:指摘 3 件(行末・区切りコメントの選択,公開 getter の広さ,括弧付きの return)は,レビュー 1
回分の方針により直さず Limits に記録した.どの thread も返信して resolve 済み.

## テスト

- `uv run pytest`:replay を含む model rule のテストが通過.
- `jev-lint eval --replay`:74 suite すべて通過.
- ruff,ty(pre-commit)は通過.

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

---------

Co-authored-by: furedea <132188853+furedea@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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