Skip to content

fix(hooks): skip commits already on the default branch in model rules - #247

Merged
furedea merged 2 commits into
mainfrom
fix/stop-rules-skip-merged
Nov 19, 2026
Merged

furedea merged 2 commits into
mainfrom
fix/stop-rules-skip-merged

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

概要

Stop hook の model rules が,default branch に取り込まれた commit(他の作業,または既にレビュー済みの自分の PR)のファイルまで判定していた.判定の基準を単純な方法で見直す.

Closes #234
Refs #169

方法

commit 済みの変更の基準(base)を,セッション開始時の HEAD と git merge-base HEAD refs/remotes/origin/HEAD のうち新しい方にする.

  • 後者が前者の子孫のとき(git merge-base --is-ancestor)だけ使う
  • remote の default branch が分からないとき,または子孫でないときは,従来どおりセッション開始時の HEAD
  • committed_paths,ADR の選択(ReviewedSpan),Review の --base が同じ base を使う(review_base を model_rules_files.py に追加)

#237 の reflog 解析は重すぎるため使っていない.

  • receipt の fingerprint(_inputs)に解決後の base を含める(review の指摘 P1/P2 への対応)

テスト

  • default branch に入った commit は判定せず,その後の自分の commit だけ判定する
  • default branch が開始時の commit につながらないときは,開始時の HEAD を base にする
  • default branch が Stop の間に進んだら,古い receipt を再利用せず判定し直す
  • 既存テストのうち _Changes を直接組み立てる 2 件に base を渡すよう更新

範囲外(Issue #234 のコメントと brief による)

自分の commit を隠す迂回(fast-forward,default branch への rebase,reflog 編集),merge commit の conflict 解決,default branch を持たない repository,#245.

レビュー指摘の扱い

  • P1/P2(fingerprint に base が無い): 修正済み
  • MEDIUM(agent が書ける ref から base を決める,security review): 範囲外.agent が自分の commit を隠す迂回(default branch への rebase,ref の書き換え)に当たり,rules は advisory で,漏れても 1 件を見逃すだけ(brief の threat model)
  • P2(Stop 中の背景 git fetch が fingerprint と review の 2 回の review_base の間に ref を動かす競合): 範囲外.rules は advisory で,漏れても次の Stop までの 1 件を見逃すだけ(brief の threat model)

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 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-18T08:59:08.620043Z 1bc216a Manual request
ℹ️ About Codex in GitHub

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

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

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

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

Copy link
Copy Markdown

Review summary

The change is small and the base logic reads correctly. --is-ancestor exits non-zero and is mapped to None, so it falls back to the session-start HEAD. When HEAD equals the new base, nothing is reviewed. I did not run the tests.

Findings

  • P2: _inputs() in model_rules_gate.py still fingerprints record.head rather than the effective review base. A git fetch that moves origin/main without touching worktree files can make a stored receipt get reused for a different commit set. There is an inline comment on this one.

Test gaps (P3, optional)

  • No test covers the case where every session commit is already on the default branch (base == HEAD, so nothing is reviewed).
  • No test covers a repository without origin/HEAD, which should fall back to the session-start HEAD.
  • No test covers the receipt reuse described above.

🤖 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: 185595a5f7

ℹ️ 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 Resolved
…print

Co-Authored-By: Claude Sonnet 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: no blocking findings.

I read the diff for correctness, security and test coverage.

  • review_base handles both exit paths of git merge-base --is-ancestor. Exit 0 prints nothing, which the code treats as success because it checks for None and not for a truthy value. Exit 1 raises CalledProcessError and falls back to the session's starting HEAD.
  • _Changes.of, Review --base and the _inputs fingerprint now all use the same resolved base. This fixes the stale-receipt problem, and the third new test covers it.
  • The except A, B: syntax matches the rest of the file and the >= 3.15 requirement in pyproject.toml.
  • The tests cover a commit already on the default branch, a default branch unrelated to the session's starting commit, and a default branch that moves between Stops.

Optional, P3: refs/remotes/origin/HEAD is a remote-tracking ref, so a git push of the session's own commits straight to the default branch also moves the base past them. That is consistent with the PR's stated out-of-scope list and its advisory-rules threat model, but you may want it documented.

🤖 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: 1bc216ac5d

ℹ️ 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 Resolved
@furedea
furedea merged commit 3df49a2 into main Nov 19, 2026
29 checks passed
@furedea
furedea deleted the fix/stop-rules-skip-merged branch November 19, 2026 01:11
furedea pushed a commit that referenced this pull request Nov 19, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.3.0](v0.2.0...v0.3.0)
(2026-11-19)


### Features

* **lint:** fit the bash and yaml model rule cutoffs
([#243](#243))
([d5eab6b](d5eab6b))
* **lint:** fit the Go model rules on eval fixtures
([#244](#244))
([cf87c36](cf87c36))
* **lint:** fit the Rust model rules to eval fixtures
([#241](#241))
([3275ce2](3275ce2))
* **lint:** fit the TypeScript model rules on eval fixtures
([#242](#242))
([bb41bb7](bb41bb7))
* **lint:** make bash_local_underscore_prefix an error
([#251](#251))
([cd8c5b8](cd8c5b8))


### Bug Fixes

* **hooks:** let cleanup_worktrees remove worktrees left with only
regenerable outputs
([#235](#235))
([a25ce5b](a25ce5b))
* **hooks:** raise the model rules subject cap and keep cached findings
under it ([#246](#246))
([a451e93](a451e93))
* **hooks:** show each Stop model-rule finding once per session
([#252](#252))
([49cd6f9](49cd6f9))
* **hooks:** skip commits already on the default branch in model rules
([#247](#247))
([3df49a2](3df49a2))

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

fix(hooks): judge only the session's own changes in Stop model rules

1 participant