Skip to content

test(hooks): map agent-config sources to the tests their names miss - #12

Merged
furedea merged 3 commits into
mainfrom
test/related-test-map
Oct 24, 2026
Merged

furedea merged 3 commits into
mainfrom
test/related-test-map

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

概要

Stop 検証フックは,プロジェクトに .agents/hooks/rules/related_test_extensions.json がなければファイル名だけでテストを選ぶ.agent-config は dotfiles から分かれて以来この表を持たず,ルール JSON や設定,共有のフック用ライブラリを変えても tests/test_command_permission_sync.py のような名前の合わないテストが選ばれなかった.

Refs #8(実装計画: #8 (comment) の test-map レーン)

変更内容

  • .agents/hooks/rules/related_test_extensions.json を追加
    • dotfiles 版(8e61ceb^)の表を tests/agents/... から tests/... へ読み替えた
    • dotfiles に残ったファイル(nix/**,zsh/,herdr/ など)と,消費するテストがない flake.nix・flake.lock・.gitignore の項目は外した
    • agents/hooks/*.py と agents/codex/hooks/*.py は外した.fnmatch の * は / もまたぐため,lib/ 配下の未対応モジュールまで test_python_runtime.py だけに割り当て,全体テストへのフォールバックを止めていた.代わりに描画される entry point を個別に対応させた
    • agent-config にだけある消費側を足した:herdr の所有権,worktree の片付け,shell_inspection,herdr_grammar,replay,provider アダプタ,検証の状態・再利用・ロック待ち,explain-visually スキルの assets など
    • ソースを実際には読まないテスト先(agents/AGENTS.md → test_guard_file.py,secret_* JSON → test_verification_rule.py など)は外した
  • tests/test_related_test_extensions.py を追加
    • すべてのパターンが作業ツリーに存在するファイルに一致し,すべてのテスト先が存在する
    • 代表的なソースを変えたとき,実際の check_selection.language_plan が名前で一致しないテストを選ぶ
    • 未対応のフック用モジュールにはどのパターンも一致せず,全体テストへのフォールバックが残る

確認

  • 新しいテストは表がない状態で失敗し,表を置くと 24 件すべて通る
  • uv run --frozen pytest:2530 passed(初回コミット時点)
  • 共有 verify:passed
  • ruff check,ruff format --check,ty check:問題なし
  • CI:all-green pass

レビュー

  • Codex レビューの P2 5 件,P3 2 件はすべて対応済み.再レビューで残った P2 1 件(defaults JSON → test_hook_lock_wait.py)も対応した

計画との差分

なし.tests/bootstrap_server.bats は描画済みの settings.json を読むが,bootstrap レーンの範囲なので表には入れていない

🤖 Generated with Claude Code

furedea and others added 3 commits October 24, 2026 18:25
The Stop verification hook selects tests by file name unless the project
declares related_test_extensions.json. agent-config had none since the
split from dotfiles, so changes to rule JSON, settings, and shared hook
libraries missed consumers such as tests/test_command_permission_sync.py.

Port the dotfiles mapping to the tests/ layout, drop entries for files
that stayed in dotfiles, and add the agent-config-only consumers (herdr
ownership, worktree cleanup, shell inspection, entry points, skill
assets). A contract test checks that every pattern matches a repository
file, every target exists, and representative sources select the tests
their names do not match.

Refs #8

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Drop the agents/hooks/*.py and agents/codex/hooks/*.py patterns: fnmatch
lets * cross directories, so they claimed every hook module for
test_python_runtime and suppressed the full-suite fallback for sources
without their own mapping. Name the rendered entry points instead.

Add consumers that read or load the mapped sources (codex config and
herdr ownership for settings and hooks.json, replay and provider tests
for the guards, verification status/reuse/lock tests for the check
modules, audit and suppression tests for the input parsers), and drop
targets that never read the source. Only count index paths that still
exist when checking that patterns match repository files.

Refs #8

Co-Authored-By: Claude Opus 5.5 <[email protected]>
test_hook_lock_wait.py runs Stop verification through
session_gate.selected_checks(), which reads related_test_defaults.json.

Refs #8

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@furedea
furedea merged commit 2f51764 into main Oct 24, 2026
13 checks passed
@furedea
furedea deleted the test/related-test-map branch October 24, 2026 11:48
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