Skip to content

feat(hooks): show model-rule timing and skip rule fixtures - #157

Merged
furedea merged 6 commits into
mainfrom
feat/74-model-rules-resume
Nov 11, 2026
Merged

furedea merged 6 commits into
mainfrom
feat/74-model-rules-resume

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

概要

Stop のモデル判定について,判定にかかった秒数と,上限で見送った数を Stop の表示に出します.また,ルールの例(fixtures)はわざと違反を含むので,モデル判定の対象から外します.

計画:https://github.com/furedea/agent-config/issues/74#issuecomment-6795489555(レーン A)

続きからの判定は入れませんでした

当初は,上限で見送った対象を次の Stop で続きから判定する仕組みを入れていました.しかし jev-lint review --dry-run はレビュー全体の件数しか返さず,保存結果に何が入っているかを件数から推測する設計でした.レビューのたびに,その推測が外れる別の場合が見つかりました(上限を超えるファイル,2 つのレビューでの共有,保存結果の変化,保存結果に以前の判定が混ざる場合).そのため,ユーザーの判断で仕組みごと取り除きました.受領書は,入力が変わらなければ今までどおり再利用します.見送った対象を後で判定する方法は,別の設計(判定した対象の内容ハッシュを受領書に残す)で検討します.

変更内容

項目 変更前 変更後
Stop の表示 要求数,保存結果の数,見送った数 + judged N of M subject(s) in X.Xs(判定した数と秒数)
受領書を答えに使う関数 _reused(読むだけに見えるが,未提示の指摘を提示済みに更新する) _answer_from(名前が純粋な読み取りを約束しない)
ルールの例 他のファイルと同じく送る agents/hooks/lint/model-rules/**/fixtures/** は送らない
  • SUBJECT_CAP,BUDGET_SECONDS,600 秒の hook タイムアウトは変えていません(実測をもとに別の PR で決めます).
  • 新しい指摘は 1 回だけブロックし,変わらない指摘は通知だけにし,stop_hook_active 中の指摘を失わない,という既存の決まりも変えていません.

設計上の判断

  • ルールの例の除外は,jev-lint の --exclude ではなく,送るファイルを選ぶ select(model_rules_files.py)で行います.モデルに送る範囲をこのフックが決めるので,jev-lint の挙動に頼らず,テストで確かめられます.PurePosixPath.full_match で agents/hooks/lint/model-rules/**/fixtures/** に一致するパスだけを除くので,tests/fixtures/ のような別の場所の fixtures は送ります.
  • 除外したファイルは,存在しないファイルや - で始まるパスと同じく,数えずに黙って外します.名前を表示しないという既存の方針とも矛盾しません.

確認

内容 結果
表示のテスト 4 件,除外のテスト 2 件(先に失敗を確認してから実装) 通過
uv run pytest tests/hooks tests/test_hook_generation.py 3710 passed, 1 skipped
uv run ruff check / uv run ty check 通過
pre-commit(file-length, commitlint など) 通過

実際のモデル呼び出しは使っていません(偽の jev-lint と op で境界を確認).

計画からの変更点

計画のレーン A のうち,「見送った対象を次の Stop で続きから判定する」は入れていません(上記).ほかに,ルールの例を判定の対象から外す変更を足しました.

Refs #74

🤖 Generated with Claude Code

The Stop message now tells the seconds the model-rules review took and how many
subjects were judged or skipped by the cap.

A receipt whose last run skipped files is no longer final: the next Stop on the
same inputs judges the skipped files first. The files judged before are passed
again, so the verdict cache answers them, and only findings the agent has not
been shown block. A file larger than the whole cap is reported but never
resumed.

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-11T13:31:43.843316Z 431fa48 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread agents/hooks/lib/model_rules_run.py Outdated
per_file[batch["file"]] = per_file.get(batch["file"], 0) + _count(batch, "subjects")
chosen: list[str] = []
# The report does not say which subjects are cached, so a resumed run takes the files it judged before for free.
chosen = [file for file in per_file if pending and file not in pending and _passable(file)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: on a resumed Stop, files that were never judged get sent as if they were cached, and they don't count toward the cap.

This line treats every passable file that isn't in pending as "judged before, sits in the verdict cache". Some files that aren't in pending were skipped and never judged. The clearest case is a file with more subjects than SUBJECT_CAP: line 239 leaves it out of resumable on purpose.

Example: per_file = {"huge.py": 40, "a.py": 5, "b.py": 18}.

  • First Stop: only a.py is judged (5). huge.py and b.py are skipped, and resumable = ("b.py",).
  • Second Stop on the same inputs: pending = {"b.py"}. This line adds huge.py and a.py to chosen for free, then b.py fits (18 ≤ 20). jev-lint is called with huge.py, so it judges 40 uncached subjects plus 18. That is 58 model subjects against a cap of 20.

Exceeding the cap costs money, and it can also run past the 90 s budget. If it times out, _unfinished keeps the old receipt, which is still resumable. So every later Stop on the same inputs runs again and can time out again, and the review never finishes.

The same thing happens with the shared cap across reviews. A file skipped by one review but listed only in another review's plan can be sent for free here without having been judged.

Fix: record the files that were actually judged (or every file that was skipped, resumable or not) in the receipt. Then send for free only the files that were judged before. Don't assume everything outside pending is cached.

Missing test: test_a_file_larger_than_the_cap_is_reported_but_never_makes_the_stop_resume only checks the case where nothing else is resumable. There's no test for an over-cap file combined with a resumable file, which is the case that leaks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f4ceea1. A resumed run now sends for free only files the cap can admit (_admissible: passable and subjects <= SUBJECT_CAP). A file over the whole cap was never judged, so it is no longer treated as cached. The new test test_a_resumed_stop_never_sends_a_file_larger_than_the_cap_that_was_not_judged_before uses your example shape (huge.py 40 plus a, b, c) and failed before the fix.

On the shared cap across reviews: a file that one review skipped for the cap is named in resumable, and pending is matched by file name in every review, so it competes for the cap again wherever it appears. A file that is oversize in one review but fits in another is judged or named by that other review under the same rule, so no file is sent unjudged and uncounted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

@github-actions

Copy link
Copy Markdown

Review summary

1 blocking finding (P1).

  • P1 agents/hooks/lib/model_rules_run.py:231: on a resumed Stop, _capped_plan treats every file outside pending as already judged and cached, and sends it without counting it toward the cap. A file with more subjects than SUBJECT_CAP is skipped but never named in resumable, so it gets sent with all its subjects uncached as soon as any other file resumes. This goes over the cap of 20. It can also time out, and since a timeout leaves the receipt resumable, every later Stop on the same inputs runs again. No test covers an over-cap file together with a resumable file.

Otherwise the receipt handling looks right: shown/UNSHOWN and stop_hook_active, reusing the receipt only once nothing is skipped, and falling back to the receipt when a resume can't run. Older receipts without resumable or shown are still reused as before.

🤖 Generated with Claude Code

A resumed Stop passes the files outside the pending set again because their
verdicts are cached. A file with more subjects than the whole cap was never
judged, so it is not cached, and resending it exceeded the cap and could time
out on every later Stop. Only files the cap can admit count as judged before.

Refs #74

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

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/model_rules_gate.py Outdated
"""Answer from a receipt for the same inputs; findings the agent has not seen yet still block, once."""
summary = receipt["summary"]
if receipt.get("outcome") == UNSHOWN and not self.stop_hook_active:
self.record.save_results({**self.record.results(), RECEIPT_KEY: {**receipt, "outcome": SHOWN}})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 — _reused changes outcome to SHOWN but never adds the findings to shown. The receipt is still resumable, so this matters when we arrive here through _unfinished.

Scenario:

  1. A Stop with stop_hook_active finds new finding B. It saves UNSHOWN with resumable=[x], and shown does not include B.
  2. On the next Stop, the resume is prevented (timeout or exit status). _unfinished → _reused blocks with B and saves outcome=SHOWN. shown still does not include B.
  3. On the next Stop, the receipt is still resumable, so the review runs again. B is not in shown, so fresh is true and the Stop blocks again on B, which the agent has already seen.

This breaks the rule "new findings block only once". test_a_stop_that_cannot_resume_keeps_the_unseen_findings_for_the_agent only checks the first block, not the Stop after it. Suggested fix: when moving to SHOWN, also merge the receipt's findings into shown. The receipt only has the summary today, so it would also need to store the keys of the UNSHOWN findings.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e72f499. Moving an unshown receipt to SHOWN now also moves its findings into shown: the receipt keeps the keys of the findings in its summary (found), and _reused merges them. New test test_findings_shown_by_a_block_after_a_failed_resume_do_not_block_again_when_the_resume_succeeds fails without the change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

Comment thread agents/hooks/lib/model_rules_run.py Outdated
chosen: list[str] = []
# The report does not say which subjects are cached, so a resumed run takes the files it judged before for free.
# A file over the whole cap was never judged, so it is not one of them.
chosen = [file for file, count in per_file.items() if pending and file not in pending and _admissible(file, count)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 — A resumed run passes every file that is not in pending without charging it to the cap. This assumes all of their subjects are in the verdict cache, and nothing checks that. The set of free files also grows with each resume: after k resumes, about 20·k subjects are passed for free.

The assumption fails if the shared verdicts.json changed between Stops (another session, eviction, a cache that was deleted or reset), or if the earlier run did not cache some verdicts. In that case one Stop can send many more than SUBJECT_CAP uncached subjects to the model. That breaks the cost bound the cap exists for, and it can also exceed the 60s judge timeout, which then gives a Prevented on every resume.

pending is also one set shared by the committed and the uncommitted review. A file that one review judged and the other skipped is pending in both, so it uses cap in the review that already judged it. Consider charging subjects - cached from the dry-run against the cap as a backstop. For example, fall back to the normal capped selection when the free files' share of the uncached count is larger than the cap.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e72f499. The files judged before are resent only while the dry run agrees with the cache: the uncached count must not exceed the subjects of the files never judged (the pending files plus those over the whole cap). If it does, the cache no longer answers for them, so none are resent and the pending files compete for the cap alone; the cost stays within the cap. The free set also does not grow without bound because of that check. Test: test_a_resumed_stop_does_not_resend_the_files_judged_before_when_the_verdict_cache_no_longer_has_them. Pending is now per review as well (see the Codex thread).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings (no P0 or P1). Two P2 issues:

  • P2 model_rules_gate.py:103: when a resume can't run, _unfinished → _reused blocks with the unseen findings and marks the receipt SHOWN, but doesn't add those findings to shown. The receipt is still resumable, so the next Stop that resumes successfully blocks again on the same findings. The existing test only checks the first block.
  • P2 model_rules_run.py:232: a resumed plan passes every file outside pending without charging it to the cap. It assumes they are all in the verdict cache, but nothing checks that. If the shared cache changed, one Stop can send many more than SUBJECT_CAP uncached subjects. The free set also grows with each resume.

The rest looks correct: the progress guarantee for files that fit the cap, leaving out files that are too big or start with -, the shown set on the normal paths, and the timing footer.

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

ℹ️ 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_gate.py Outdated
Comment on lines +102 to +104
if receipt.get("outcome") == UNSHOWN and not self.stop_hook_active:
self.record.save_results({**self.record.results(), RECEIPT_KEY: {**receipt, "outcome": SHOWN}})
return Advice(summary, blocking=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 再利用時にも提示済みの指摘キーを記録してください

stop_hook_active 中に未提示の指摘を保存した後,再開処理がタイムアウトや実行エラーになった場合,_unfinished() はここで受領書を SHOWN に変えて一度ブロックしますが,shown 配列は空のままです.その後の Stop で再開に成功すると,同じ指摘が _conclude() で再び新規と判定され,変更のない入力に対して二度目のブロックが発生します.SHOWN へ遷移するときは,その要約に対応する未提示キーも shown に移す必要があります.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e72f499 (same change as the reply in the claude-review thread): the findings of an unshown receipt are added to shown when it becomes SHOWN, so a later successful resume no longer blocks twice on them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

Comment thread agents/hooks/lib/model_rules_gate.py Outdated
Comment on lines +219 to +220
model_rules_run.Review(
record.root, None, RULES_DIRECTORY, cache, programs, self.uncommitted.sendable, pending

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 再開対象をコミット済みと未コミットのレビュー別に保持してください

同じパスにコミット済み変更と未コミット変更の両方がある場合,単一の pending 集合を両レビューへ渡すと,一方で見送られたパスが他方でも未判定扱いになります.特にコミット側に上限超過で再開不能な別ファイルがあり,共通パスが上限を使い切る場合,コミット側は保存済みの共通パスを毎回コストとして選び,未コミット側には上限が残らないため,同じパスが永続的に resumable に残って作業ツリーの変更が判定されません.再開対象にはレビュー種別または base を含め,該当するレビューだけへ渡す必要があります.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e72f499. The receipt now stores each skipped file with its review (committed or uncommitted, type Resumable), and each review receives only its own files as pending. A file skipped in one review no longer competes for the cap in the other. Test: test_each_review_resumes_only_its_own_skipped_files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

…findings shown

Three review findings on the resume of skipped subjects:

- A block that reuses an unshown receipt now records its findings as shown, so
  a later successful resume does not block again on the same findings.
- Skipped files are remembered per review (commits and uncommitted changes), so
  a file skipped in one review no longer competes for the cap in the other.
- The files judged before are resent only while the dry run's uncached count
  matches the files never judged. If the verdict cache lost them, they are not
  resent and the skipped files compete for the cap alone.

Refs #74

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

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/model_rules_run.py Outdated
total = 0
for file, count in per_file.items():
if not file.startswith("-") and total + count <= cap:
if (not pending or file in pending) and _passable(file) and total + count <= cap:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: 共有の上限のもとで,続きからの判定が進まなくなることがある.

review_all は cap = max(0, cap - plan.cost) で上限を減らします.一方で pending のない通常の経路では,cost(total)が選んだファイルの件数をキャッシュ済みのものも含めて数えます.そのため,committed 側に上限を超える 1 ファイルか - で始まるファイルがあると,committed は毎回 subjects - cached > cap の経路に入り,キャッシュ済みのファイルで上限を使い切ります.

例:committed = X(25 件,admissible ではない)+ A(20 件),uncommitted = D(5 件).

  • 1 回目:committed は A を選ぶ(cost 20)→ uncommitted の cap は 0 → D は見送られ,resumable [(uncommitted, D)] になる.
  • 2 回目:committed の pending は空なので同じ計画になる(A は キャッシュ済みでも cost 20)→ cap は 0 → D はまた見送られ,resumable [D] になる.
  • これがずっと繰り返されます.受領書は最終にならず,Stop のたびに dry-run と判定がやり直され,表示は judged at the next Stop と言い続けますが,D は判定されません.

修正案:通常の経路でもキャッシュ済みの件数を cost に入れない.あるいは,どこかの review に pending があるときは,pending のない review の cost を 0 として扱う.このケース(他の review に admissible ではないファイルがあるときに,pending が上限を争う)のテストもあるとよいです.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f0d3e1c. The receipt now records, per review, the files it passed to the model (reviewed), and the cost counts only files that are not answered by the cache. In your example the second Stop sends A for free (cached), X stays skipped as over the cap, so the uncommitted review keeps the full cap and judges D. Test: test_files_judged_before_do_not_use_up_the_cap_the_other_review_needs (it fails with the old cost rule: D stays skipped and the message still says "judged at the next Stop").

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

@github-actions

Copy link
Copy Markdown

レビューの要約

指摘は 1 件(P2)です.マージを止める指摘(P0/P1)はありません.

  • P2 agents/hooks/lib/model_rules_run.py:241:pending のない review が,キャッシュ済みのファイルの件数を共有の上限から引いてしまいます.そのため,別の review(committed 側に上限を超えるファイルや - で始まるファイルがあるとき)で見送ったファイルが,毎回上限 0 になって判定されず,受領書が最終にならないまま Stop のたびにやり直されます.

ほかに確認して問題がなかった点:

  • 受領書の shown / found による 1 回だけのブロック
  • stop_hook_active 中の指摘を次の Stop に持ち越すこと
  • 続きが失敗したときに受領書から答えること
  • キャッシュが失われたときに _judged_before が判定済みのファイルを送らないこと
  • review ごとに分けた pending

新しいテストは主な経路を押さえています.

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

ℹ️ 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_run.py Outdated
Comment on lines +259 to +262
never_judged = sum(count for file, count in per_file.items() if file in pending or not _admissible(file, count))
if uncached > never_judged:
return []
return [file for file, count in per_file.items() if file not in pending and _admissible(file, count)]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge キャッシュの内訳が不明なら判定済みファイルを再送しないでください

共有 verdict cache で,前回見送ったファイルの結果が別セッションによって追加される一方,以前判定したファイルの結果が失われた場合,集計値だけではどのファイルが cached か判別できません.例えば先行する committed review が上限を使い切って cap == 0 でも,pending の 30 subject が cached,それ以外の 20 subject が uncached なら uncached <= never_judged となり,この return が uncached な既判定ファイルをすべて選びます.それらは total に加算されないまま judge に渡されるため,Stop 全体の 20 subject 上限を超えて有料のモデル判定が実行されます.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in f0d3e1c. Files judged before are now sent for free only when the dry run matches exactly: the uncached count must equal the subjects of the files not reviewed before. Any other count (a pending file cached by another session, a reviewed file evicted) means the cache changed, so nothing is sent for free and the not-yet-judged files compete for the cap alone. Your example (pending cached, others uncached) now gives uncached below the expected count and is refused. Test: test_a_resumed_stop_trusts_the_cache_only_when_the_dry_run_matches_what_it_judged.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

…esume

Two more review findings on resuming skipped subjects.

The cost of a review counted the subjects of files that the verdict cache
already answers, so a file judged before could use up the cap another review
needed and keep a skipped file from ever being judged.

The receipt now records, per review, the files it passed to the model. Those
files are resent without cost only while the dry run's uncached count equals
the subjects of the other files exactly. Any other count means the verdict
cache changed, so nothing is resent for free and the files not judged yet
compete for the cap alone.

Refs #74

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

furedea commented Nov 11, 2026

Copy link
Copy Markdown
Owner

@codex review

Comment thread agents/hooks/lib/model_rules_run.py Outdated
not reviewed before exactly when the cache holds everything that was reviewed and nothing else. Any other count
means the cache changed (another session, eviction), so nothing is sent for free and no cost is hidden.
"""
expected = sum(count for file, count in per_file.items() if file not in reviewed)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: the resume can loop forever and never judge some files when the verdict cache already held subjects before this Stop.

The cache keeps verdicts per subject and is shared across sessions and across earlier inputs. So it is common for the dry run's cached count to include subjects outside reviewed, for example subjects in b.py/d.py that an earlier Stop judged before the last edit. When that happens, uncached != expected on every resume and _answered_by_cache returns []. The files judged before then sort last and compete for the cap again. reviewed is also rebuilt from this run's plan.paths only, so a fallback run forgets the earlier reviewed set.

Walkthrough with FOUR_FILES (a=12, b=15, c=8, d=15), assuming b or d had a few subjects cached before the session:

  • Stop 1: judges a and c. reviewed={a,c}, resumable={b,d}.
  • Stop 2: mismatch, so only b fits. reviewed={b}, resumable={a,c,d}.
  • Stop 3: mismatch again. a and c are now "not reviewed", so they go first and fill the cap at 20. reviewed={a,c}, resumable={b,d}.
  • Stop 4 is the same as Stop 2, and the cycle repeats.

d.py is never judged. The receipt never becomes final, and every Stop on these inputs runs op/jev-lint and prints "judged at the next Stop". Possible fixes:

  • Accumulate reviewed across runs, taking the union with the receipt's value.
  • Make the free-pass check tolerant, e.g. uncached <= expected.
  • At least guarantee progress by preferring files never passed in any earlier run.

No test covers a cache that holds subjects outside reviewed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

@github-actions

Copy link
Copy Markdown

Review summary

  • P1: _answered_by_cache in agents/hooks/lib/model_rules_run.py only trusts the verdict cache when the uncached count matches exactly. When the cache already held subjects before this Stop (it is shared across sessions and across earlier inputs), the check fails on every resume. reviewed is also rebuilt from only the last run's paths, so the resume can cycle between the same files. Some resumable files then never get judged, and every Stop reruns jev-lint without the receipt ever becoming final. Details are in the inline comment.

The rest looks correct: blocking based on shown/found, the fallback to the receipt when a resume cannot run, the per-review reviewed bookkeeping, and the timing footer. The tests cover the main resume paths well. The gap is the partially pre-populated cache case above.

Blocking findings: 1 (P1).

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

ℹ️ 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_gate.py Outdated
Comment on lines +88 to +90
if not outcome.findings:
message = model_rules_report.describe_clean(outcome)
self._save(CLEAN, message, outcome)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 空の再開結果でも未提示の指摘を保持してください

最初の上限制限付き実行が stop_hook_active 中に指摘を保存し,次の Stop までに共有 verdict cache からその判定済みファイルが失われた場合,再開処理は未判定ファイルだけを送るため outcome.findings が空になり得ます.この分岐は以前の UNSHOWN な found を確認せず受領書を CLEAN で上書きして非ブロックで返すので,その Stop でセッションが終了すると保存済みの指摘が一度も提示されません.空の再開結果でも,既存受領書の未提示指摘を保持してブロック判定に含める必要があります.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The resume was removed in 9f0697a by user decision. A receipt for unchanged inputs is reused as before, so this code no longer exists.

furedea and others added 2 commits November 11, 2026 22:25
The resume inferred what the verdict cache holds from the dry run's aggregate
counts, and every review round found another way for that inference to be
wrong. A receipt for unchanged inputs is reused as before.

What stays is the report: the Stop message tells the seconds the review took,
how many subjects were judged, and how many subjects in how many files the cap
skipped. The function that answers from a receipt and may update it is named
`_answer_from`, so that its name does not promise a pure read.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The fixtures under agents/hooks/lint/model-rules/**/fixtures/** hold
violations on purpose. Judging them only reports what they are for and spends
the subject cap on them, so they are not sent.

Refs #74

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea-agent furedea-agent Bot changed the title feat(hooks): resume skipped model-rule subjects and show review timing feat(hooks): show model-rule timing and skip rule fixtures Nov 11, 2026
@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, no P2/P3 posted).

Checked:

  • PurePosixPath.full_match needs Python 3.13+; pyproject.toml requires >= 3.15.2, so OK.
  • The fixture exclusion is in select, which both the committed (--base) and the uncommitted selections go through, so fixtures can't be sent through either review. When only fixtures changed, reviews is empty, the credentials are never loaded, and the result is a clean judged 0 of 0 message.
  • seconds defaults to 0 in each Judgement and is set once in _advise after combined, so it is not counted twice. A reused receipt shows the timing from the original run, which fits not rerun.
  • judged = subjects - skipped_subjects matches the footer and the new tests (20 of 35; 1 of 1 when clean).
  • The tests cover the timing and count line, the cap message, receipt reuse after the cap, fixture exclusion, and a fixtures directory elsewhere still being sent.

🤖 Generated with Claude Code

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 431fa48fbd

ℹ️ 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 d0c32ae into main Nov 11, 2026
24 checks passed
@furedea
furedea deleted the feat/74-model-rules-resume branch November 11, 2026 14:29
furedea added a commit that referenced this pull request Nov 11, 2026
…l fixtures (#163)

## 概要

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)は利用者が実行しました.鍵はエージェントが読んでいません.

## 計画との差分

- 計画の「違反の例を今までどおり見つけられ,4 件の指摘が消える」は,M-21 は `state`,M-05
は原則とカットオフで満たしました.
- 計画になかった追加:M-05 の fixtures の増加(カットオフを当てるため),baseline.json の保存,fixtures
の ruff / ty / vulture 除外,TypeScript M-21 のカットオフ 0.75(`projectTargets` の
fixture を追加した結果).
- Stop 検証が fixtures を変更扱いして失敗する問題は,別 PR(#157,#160)で直りました.

🤖 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-agent Bot pushed a commit to furedea/dotfiles that referenced this pull request Nov 11, 2026
Pick up the model-rules timing line and the exclusion of rule fixtures from
the Stop review and test verification (furedea/agent-config#157, #160).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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