Repository navigation
fix: pr-reviewer の hooks frontmatter を block-style YAML に書き換える - #2415
Conversation
flow-style で複数物理行にまたがる hooks: 記法が fresh Claude Code process (canonical main root、worktree 不使用)で YAML Parse error を起こし、 pr-reviewer SubAgent が discovery されない不具合を修正する。 意味内容(matcher・PreToolUse 9 handler・SessionStart 1 handler・ PostToolUse 1 handler の if/command/args/timeout)は完全に維持し、 記法のみを block-style(インデント形式)へ変更した。 - AC1: hooks: が block-style で記述されている(block_style 確認済み) - AC2: 変更前後の yaml.safe_load() 結果が完全一致(EQUAL 確認済み) - AC3: Node.js yaml パッケージでのパースが成功(PARSE_OK 確認済み) Co-Authored-By: Claude Sonnet 5 <[email protected]>
Preview URL✅ verified live assets: https://squne121.github.io/loop-protocol/pr-2415/ The preview will be removed when this PR is closed. |
block-style 全展開により test_agent_body_line_count_is_thin (line_count < 90) が FAIL していたため、PreToolUse/SessionStart/PostToolUse のトップレベルキーは block-style のまま維持しつつ、各配下の matcher/hooks 値を単一物理行の flow-style mapping に戻し、ファイル総行数を87行に削減する(意味内容は不変)。 Closes #2414
Review SummaryPR #2415 ( Independent verification performed (not relying on PR self-report):
No blockers found. Verdict: APPROVEverdict: APPROVE
reviewed_head_sha: "99ae2bea69bc04891ef63a96d1f20ceb3795c267"
blockers: []
warnings: []Relevant paths:
Per this SubAgent's constraints, I have not posted this to GitHub — the calling orchestrator should post this verdict body via |
判定REQUEST_CHANGES — ただし修正方向そのものは妥当で、必要なのは主に「実 consumer での動作証明」です。 現在の PR head は 敵対的レビュー findings
スコープを広げる必要はあるかありません。 検索した範囲では、actual agent definition で今回と同じ また #1909 が同じ 推奨する最小着地PR の実装は基本的に残す。大掛かりな guard / schema / CI harness は増やさない。 必要なのは、Issue #2414 に actual-Claude runtime AC を1つ追加し、current head で実行して証跡を残すことです。その smoke が PASS したら、nested hooks の完全 block-style 化は「今回ついでにやると望ましい」程度で、必須にはしなくてよいです。 これは PR #2398 の過去レビューで採用している「CI が green かではなく、テストが production path の意味を本当に証明しているかを見る」という基準とも整合します。PR #2398 ではまさに「テストが保証する意味と実運用の意味がずれている」ことを blocker として扱っています。 actual Claude Code の fresh discovery smoke が current head で PASS すれば、私はこの PR を APPROVE に切り替えてよいと判断します。 現時点では、その一点が欠けているため |
|
All acceptance criteria were independently re-verified against the current PR head, all required CI checks pass, the Allowed Paths gate reports Verdict: APPROVEVerification performed
No blockers found. verdict: APPROVE
reviewed_head_sha: "70678e7dea6d353f3346b6dda3e7aefa8b293a1f"
blockers: []
warnings:
- "AC4 evidence's agent_transcript_verified field is False (subagent .jsonl transcript not retained on disk); corroborated instead via native session meta.json (agentType/toolUseId match) and the hook_id_correlated causal_evidence_source, which does not depend on transcript retention."Note: this PR is currently Relevant paths: |
Summary
.claude/agents/pr-reviewer.mdのhooks:frontmatter を、意味内容を一切変えずに flow-style(複数物理行にまたがる{/[記法)から block-style YAML(インデント形式)へ書き換える。fresh Claude Code process(canonical main root、worktree 不使用)でpr-reviewerSubAgent を呼び出した際にYAML Parse error: Unexpected tokenにより agent discovery が失敗する不具合(Issue #2414)を修正する。Checks
hooks:フィールドが block-style YAML で記述されている(block_styleを確認)hooks:をyaml.safe_load()でパースした結果が完全一致(EQUALを確認)yamlパッケージでパースしエラーなし(PARSE_OKを確認)pr-reviewerを discovery し、Agent tool 経由で spawn・completion できることをcausal_evidence_source: hook_id_correlatedかつexit_code: 0で確認pnpm typecheck/pnpm lint/pnpm test/pnpm build: 対象ファイルはいずれのパイプラインにも含まれないため無影響を確認(tsconfig.jsonのincludeはsrcのみ、eslint.config.mjsに markdown plugin なし、vitestは.mdを対象にしない)受け入れ条件の達成状況
.claude/agents/pr-reviewer.mdのhooks:フィールドが block-style YAML(インデント形式)で記述されている。検証コマンド(AC1)を実行しblock_styleを確認した(## 検証コマンド結果参照)。hooks:の内容を Python のyaml.safe_load()でパースした結果が、修正前の内容を同様にパースした結果と完全に等価(dict として同一)である。検証コマンド(AC2)を実行しEQUALを確認した(## 検証コマンド結果参照)。yamlパッケージ(厳密パーサ)でエラーなくパースできる。検証コマンド(AC3)を実行しPARSE_OKを確認した(## 検証コマンド結果参照)。.claude/skills/worktree-agent-runtime-smokeの structured lane)が candidate head(本 PR head70678e7dea6d353f3346b6dda3e7aefa8b293a1f)の.claude/agents/pr-reviewer.mdからpr-reviewerを discovery し、Agent tool 経由で実際に spawn・completion できることを確認した。証跡ファイルartifacts/runtime-smoke/pr-reviewer-discovery-ac4/summary.mdの主要フィールド:exit_code: 0subagent_causal_evidence.causal_evidence_source: hook_id_correlated(marker 文字列のみに依存しない、最も強い evidence tier)tested_head: 70678e7dea6d353f3346b6dda3e7aefa8b293a1f(本 PR の現在の head と一致)child_agent_type_observed: pr-reviewer/effective_agent_type: pr-reviewer/requested_agent_type: pr-reviewermulti_child_lifecycle.verified: True(spawned/completed/paired agent id が全て一致し、orphan_starts・unknown_children・duplicate_completions はいずれも空)child_completion_observed: True/terminal_event_observed: True/timed_out: False(
## 検証コマンド結果の AC4 セクションに詳細を記載)検証コマンド結果
worktree
.claude/worktrees/issue-2414-pr-reviewer-hooks-block-style(head99ae2bea69bc04891ef63a96d1f20ceb3795c267)で Issue #2414 の Verification Commands を実際に再実行した結果:AC1(block-style確認)
AC2(等価性確認)
$ uv run python3 -c $'import yaml\nold_hooks = {"PreToolUse": [{"matcher": "Bash", "hooks": [\n {"type": "command", "if": "Bash(git commit *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(git push *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(git worktree *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(gh pr review *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(gh pr comment *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(gh pr merge *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(gh issue edit *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(gh issue comment *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5},\n {"type": "command", "if": "Bash(gh issue close *)", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["deny"], "timeout": 5}\n]}], "SessionStart": [{"hooks": [{"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["observe-identity"], "timeout": 5}]}], "PostToolUse": [{"matcher": "Read", "hooks": [{"type": "command", "command": "${CLAUDE_PROJECT_DIR}/.claude/hooks/pr_reviewer_guard.py", "args": ["observe-reference-read"], "timeout": 5}]}]}\ntext = open(".claude/agents/pr-reviewer.md").read()\nfm = text.split("---")[1]\nnew_hooks = yaml.safe_load(fm)["hooks"]\nprint("EQUAL" if new_hooks == old_hooks else "MISMATCH")' EQUAL $ echo $? 0AC3(Node.jsパース確認)
AC4(Scope Delta、OWNER 敵対的レビュー反映)
worktree
.claude/worktrees/issue-2414-pr-reviewer-hooks-block-style(head70678e7dea6d353f3346b6dda3e7aefa8b293a1f、本 PR の現在の head と一致)で、Issue #2414 記載の AC4 Verification Command を実行した:$ uv run --locked python3 scripts/agent-ops/run_worktree_agent_runtime_smoke.py --runtime claude --mode structured --worktree "$(pwd)/.claude/worktrees/issue-2414-pr-reviewer-hooks-block-style" --prompt-file tmp/runtime-smoke/pr-reviewer-discovery-ac4.md --output-dir artifacts/runtime-smoke/pr-reviewer-discovery-ac4 --timeout-seconds 300 --max-turns 30 --agent-type pr-reviewer --require-min-subagents 1 --expect-marker REACHABLE証跡ファイル
artifacts/runtime-smoke/pr-reviewer-discovery-ac4/summary.mdに記載された主要フィールド(そのまま引用):causal_evidence_source: hook_id_correlatedは Issue #2414 の Stop Condition が要求する最強の evidence tier(marker_only_insufficient/no_evidenceではない)であり、exit_code: 0と合わせて AC4 の成功条件(subagent_causal_evidence.causal_evidence_source == hook_id_correlatedかつexit_code == 0)を満たす。SKIP(claude実行ファイル不在等)や fallback 経路は使用していない。Allowed Paths 遵守
Issue #2414 の Allowed Paths は
.claude/agents/pr-reviewer.mdのみ。git diff --stat origin/main...HEADで確認した結果、変更ファイルは以下の1件のみであり Allowed Paths を逸脱しない。Runtime Verification Evidence(実行時検証証跡)
Issue #2414 の Runtime Verification Applicability は
decision: immediate(applicable_acs: AC1, AC2, AC3, AC4。AC4 は OWNER 敵対的レビュー #2415 (comment) を反映した Scope Delta で追加)。AC1〜AC3 は worktree
.claude/worktrees/issue-2414-pr-reviewer-hooks-block-style(head99ae2bea69bc04891ef63a96d1f20ceb3795c267、当時の worktree head。.claude/agents/pr-reviewer.mdの blob SHA は現在の head70678e7dea6d353f3346b6dda3e7aefa8b293a1fでも同一であり差分は変化していない)で Issue #2414 の Verification Commands を実際に実行して得られた生の結果である(本 PR 本文に直接埋め込み、外部コメントへの参照は行わない)。uv run python3 -c '...'(Issue 実装: pr-reviewer SubAgent の hooks frontmatter を block-style YAML に書き換え、fresh process での discovery 失敗を修正する #2414 記載の AC1 コマンド) → stdout:block_style/ exit code:0uv run python3 -c '...'(Issue 実装: pr-reviewer SubAgent の hooks frontmatter を block-style YAML に書き換え、fresh process での discovery 失敗を修正する #2414 記載の AC2 コマンド) → stdout:EQUAL/ exit code:0node -e '...'(Issue 実装: pr-reviewer SubAgent の hooks frontmatter を block-style YAML に書き換え、fresh process での discovery 失敗を修正する #2414 記載の AC3 コマンド) → stdout:PARSE_OK/ exit code:0いずれも
artifact_requirements(stdout のEQUAL/PARSE_OK/block_style文字列と exit code)を満たしている。SKIP(uv / node 不在)や fallback 経路は使用していない(uv / node は共にローカル環境に存在し、正常終了した)。AC4 は worktree
.claude/worktrees/issue-2414-pr-reviewer-hooks-block-style(head70678e7dea6d353f3346b6dda3e7aefa8b293a1f、本 PR の現在の head と一致)で実行し、artifacts/runtime-smoke/pr-reviewer-discovery-ac4/summary.mdに証跡が保存されている(主要フィールドは## 検証コマンド結果の AC4 セクションに引用済み)。SKIP や fallback 経路は使用していない。reviewed_head_sha に関する注記(再レビュー必要)
本 PR には過去に
reviewed_head_sha: 99ae2bea69bc04891ef63a96d1f20ceb3795c267に対する APPROVE コメントが存在するが、その後mainの取り込みにより現在の head は70678e7dea6d353f3346b6dda3e7aefa8b293a1fに進んでいる(.claude/agents/pr-reviewer.mdの diff 内容自体は変化していないことを確認済み)。さらにその後、OWNER 敵対的レビュー(head70678e7dea6d353f3346b6dda3e7aefa8b293a1fに対する REQUEST_CHANGES、https://github.com/squne121/loop-protocol/pull/2415#issuecomment-5466641709)により AC4(実 Claude Code process での discovery/spawn/completion 証明)の追加が要求され、本更新で AC4 を実行し満たした。したがって、本更新後は canonical pr-reviewer による現在の head(
70678e7dea6d353f3346b6dda3e7aefa8b293a1f)に対する fresh review が必要であり、reviewed_head_sha: 99ae2bea...の古い APPROVE、および AC4 追加前の REQUEST_CHANGES のいずれも現状の PR 内容(AC4 evidence 追加後)に対する verdict としては扱わない。Schema Change Applicability
hooks:の意味内容(matcher・PreToolUse 9 handler・SessionStart 1 handler・PostToolUse 1 handler の if/command/args/timeout)は完全に維持しており、YAML の記法(flow-style → block-style)のみを変更したため、consumer が受け取るデータ構造・値は変わらない。Schema Consumer Inventory
N/A
reason: schema_change ではなく、
yaml.safe_load()した結果が変更前後で完全一致(EQUAL)することを AC2 で確認済みのため、既存 consumer(Claude Code agent discovery)に対する before/after 差分は発生しない。Safety Claim Matrix
N/A
reason: 変更対象は
.claude/agents/pr-reviewer.mdの YAML frontmatter の記法のみであり、SAFETY_SENSITIVE_PATH_PATTERNS(transport / permission / sandbox / auth / mcp /.claude/skills//.github/workflows/)のいずれにも該当しない。pr_reviewer_guard.pyのロジック変更は行っておらず、hook の deny 対象コマンド・args・timeout は変更前後で完全一致する(AC2 で確認済み)。Notes
decision: immediate。AC1〜AC3 はいずれもローカルでuv run/nodeにより実行し PASS を確認済み。AC4(Scope Delta)は.claude/skills/worktree-agent-runtime-smokeの structured lane で実行し PASS を確認済み。証跡は本 PR 本文の## Runtime Verification Evidenceセクションおよび## 検証コマンド結果セクションに直接記載済み(PR コメントへの参照は行わない)。pr_reviewer_guard.pyのロジック変更、hooks:以外の frontmatter フィールドの変更もなし。.claude/agents/pr-reviewer.mdのみ変更(git diff --statで確認済み、1 file changed)。AC4 の runtime-smoke 証跡ファイル(artifacts/runtime-smoke/pr-reviewer-discovery-ac4/summary.md)は検証実行の副産物であり、Issue 実装: pr-reviewer SubAgent の hooks frontmatter を block-style YAML に書き換え、fresh process での discovery 失敗を修正する #2414 の Allowed Paths 対象コード(.claude/agents/pr-reviewer.md)の変更ではない。hooks:frontmatter のみ)が競合しないため non_conflict。.claude/agents/pr-reviewer.md)は一切加えていない。70678e7dea6d353f3346b6dda3e7aefa8b293a1f)に対する canonical pr-reviewer の fresh review が必要。