Repository navigation
fix: debounce session manifest hook noise - #1074
Conversation
squne121
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES
Mergeability
- mergeable=MERGEABLE, merge_state_status=BLOCKED
Evidence Check
- AC coverage: linked issue #1057 と fresh contract snapshot
issuecomment-4760715964は確認済み - Allowed Paths: issue #1057 の Allowed Paths 8件と PR changed files 8件は一致
- CI Verification:
ci_verdict_summary.pyは headcc6c9a7e1252ddefdd8249434fbed8643e48b2e2に対してfailedを返し、deploy-pr/lint/python-testが failure - 検証コマンド結果: test-runner の 11/11 VC PASS self-report は確認したが、単独では APPROVE 根拠に使わない
Blockers
- High:
.claude/hooks/session_manifest_coordinator.sh:95-107は guard timeout (guard_exit=124) のあとも producer を続行します。guard failure 時は producer を skip する従来契約とsession_recording_policy_guard.shの保護意図を破り、guard が hang しただけで unguarded な manifest 生成が走ります。test_timeout_reasonも timeout reason しか見ておらず、この回帰を検出していません。 Evidence:.claude/worktrees/issue-1057-session-manifest-debounce/.claude/hooks/session_manifest_coordinator.sh:95,.claude/worktrees/issue-1057-session-manifest-debounce/.claude/hooks/tests/test_session_manifest_coordinator.py:35 - High:
.claude/hooks/session_manifest_debounce.mjs:268-273の--flush経路は lock を取得していないのにrelease(WORKER_LOCK)を無条件実行します。Stop/SubagentStop の flush が実行中 worker の lock を剥がすため、直後の PostToolUse が二重 worker を spawn でき、debounce の 1-worker 前提が壊れます。 Evidence:.claude/worktrees/issue-1057-session-manifest-debounce/.claude/hooks/session_manifest_debounce.mjs:268 - Medium: required CI checks are red on reviewed head
cc6c9a7e1252ddefdd8249434fbed8643e48b2e2(deploy-pr,lint,python-test) なので、PR_REVIEW_JUDGE_VC_EVIDENCE_POLICY上も APPROVE 不可です。 Evidence:ci_verdict_summary.py --pr 1074 --repo squne121/loop-protocol --expected-head-sha cc6c9a7e1252ddefdd8249434fbed8643e48b2e2
Non-blockers
- なし
LOOP_VERDICT_V2
verdict: REQUEST_CHANGES
reviewed_head_sha: "cc6c9a7e1252ddefdd8249434fbed8643e48b2e2"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BLOCKED"
blockers:
- "high: guard timeout in session_manifest_coordinator.sh still falls through to producer; skip producer when guard exits non-zero, including timeout, and extend the timeout test to assert producer is not called"
- "high: session_manifest_debounce.mjs --flush releases worker.lock without owning it; acquire/hand off the lock correctly or avoid releasing it from forced flush"
- "medium: ci_verdict_summary.py reports failed required checks on reviewed head (deploy-pr, lint, python-test)"
required_auto_actions: []
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
allowed_paths_gate_source: review_subagent
Preview URLPreview removed (PR #1074 closed). |
|
TEST VERDICT POST ATTEMPT |
squne121
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Mergeability
- mergeable=MERGEABLE, merge_state_status=BEHIND
Evidence Check
- AC coverage: linked issue #1057 と fresh contract snapshot
issuecomment-4760715964は確認済み - Allowed Paths: issue #1057 の Allowed Paths 8件と PR changed files 8件は一致
- CI Verification:
ci_verdict_summary.pyは headd8ed7ea6cb11cff18fd4e81dfa50a24bac48896fに対してall_passを返し、required checks は green - 検証コマンド結果: test-runner の再実行で 11/11 VC PASS / TEST_VERDICT PASS / merge_state_status BEHIND を確認済みという共有と、live CI 状態は整合しています
Blockers
- なし
Non-blockers
mergeStateStatus=BEHINDのため merge-ready ではありません。branch update 後に同等証跡を維持してください。
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "d8ed7ea6cb11cff18fd4e81dfa50a24bac48896f"
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BEHIND"
blockers: []
required_auto_actions:
- kind: update_branch
executor: implementation-worker
skill: implement-issue.update_branch
blocking_merge_ready: true
mechanical: true
expected_head_sha: "d8ed7ea6cb11cff18fd4e81dfa50a24bac48896f"
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
allowed_paths_gate_source: review_subagent
squne121
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
Mergeability
- mergeable=MERGEABLE, merge_state_status=BEHIND
- draft_pr=true
Evidence Check
- AC coverage: linked issue #1057 と fresh contract snapshot
issuecomment-4760715964は確認済み - Allowed Paths: issue #1057 の Allowed Paths 8件と PR changed files 8件は一致
- CI Verification:
ci_verdict_summary.pyは headf0c7678865aea09f86f6c3111be4aa347d76a619に対してall_passを返し、required checks は green - 検証コマンド結果: shared test-runner result(11/11 VC PASS / TEST_VERDICT PASS)と live head-scoped CI 状態は整合
Blockers
- なし
Non-blockers
- Draft PR のままです
mergeStateStatus=BEHINDのため merge-ready ではありません。branch update 後に同等証跡を維持してください
LOOP_VERDICT_V2
verdict: APPROVE
reviewed_head_sha: "f0c7678865aea09f86f6c3111be4aa347d76a619"
is_draft: true
merge_ready: false
mergeability:
mergeable: "MERGEABLE"
merge_state_status: "BEHIND"
blockers: []
required_auto_actions:
- kind: update_branch
executor: implementation-worker
skill: implement-issue.update_branch
blocking_merge_ready: true
mechanical: true
expected_head_sha: "f0c7678865aea09f86f6c3111be4aa347d76a619"
auto_fix_applied: []
follow_up_issue_requests: []
allowed_paths_gate:
status: ok
allowed_paths_gate_source: review_subagent
結論判定: REQUEST_CHANGES。まだマージ不可。 現行PRは open / draft=false / head #1057 の目的は、Claude Code native async + debounce front gate により PostToolUse ごとの manifest 過剰実行と main context ノイズを抑えることです。ACには「read-only Bash は producer 0」「mutation Bash/Edit/Write は sanitized relative path / mutation type のみ」「Stop/SubagentStop は60秒以内・machine-readable timeout reason・stderr 10行以内」などが含まれます。 親 #1047 も hook/preflight/context 肥大化によるトークン浪費・ノイズ根絶が目的です。 既存レビューで指摘されていた guard timeout後にproducerへ落ちる問題 と flushが未所有lockをreleaseする問題 は、現行headではおおむね修正済みです。guard non-zero では producer に進まず exit 0 し、 ただし、より厳しく見ると別のブロッカーが残っています。 Blocker 1: Stop/SubagentStop の「flushしてからproducer」契約が lock held 時に破れる
これは docs に書かれている「pending debounce state を flush したうえで session manifest を生成する」という説明とも矛盾します。 現在のテストは「既存lockを壊さない」ことだけを確認しており、lock held でも Stop 側が bounded wait / handoff / forced flush を達成することは確認していません。 修正方針: Blocker 2: Bash read-only classifier が危険に楽観的
この実装だと、例えば以下が read-only と誤分類され、producer invocation 0 になります。 sed -i 's/foo/bar/' docs/dev/hook-boundaries.md
find . -name '*.tmp' -delete
git diff --output=patch.diff#1057 のAC4は「read-only Bash で producer 0」ですが、それは mutation Bash を落としてよいという意味ではありません。mutation Bash の取りこぼしは telemetry 欠落で、今回のIssue目的に直撃します。 修正方針: allowlistを「コマンド名」ではなく「サブコマンド + 禁止flag不在」まで見る保守的分類にしてください。迷ったら Blocker 3: detached worker 内 producer に timeout がなく、lock永久保持の経路があるPostToolUse front gate は detached worker を このため producer が hang すると worker は戻らず、 修正方針: Blocker 4: raw cwd を debounce state file に保存している
#1057 のOutcome/ACは、raw cwd / transcript / absolute path を残さず、sanitized relative path / mutation type のみを delta に残す契約です。 現在の最終producer payloadからは消えていても、worker crash・lock詰まり・debug時に 修正方針: event spool に raw Blocker 5: coordinator の scope-rollup capture が timeout/redaction/10行制限の外にある
capture script が大量stderr・absolute path・hang を起こすと、guard/producer が正しくても契約を破ります。現テストは fake guard/producer だけで、capture failure/hang/noisy stderr を検証していません。 修正方針: capture も Non-blocker: docs の説明表が一部 staleYAML manifest は
技術調査からの判断Claude Code の async hook は、発火ごとに別のbackground processを作り、複数発火間のdedupeは行いません。したがって今回の「native async + debounce front gate」という方向性自体は妥当ですが、front gate側の lock / forced flush / stale recovery が仕様上の中核になります。([Claude API Docs]4) また PostToolUse は実行後hookなので、tool call自体の副作用は既に発生済みです。よって「mutation Bashをread-onlyと誤判定してproducerを起動しない」設計は、あとから補正できない telemetry 欠落になります。([Claude API Docs]4) 投稿用レビューコメント案## Verdict: REQUEST_CHANGES
CI は current head `a2766826e35798a23a532e147e0c977c56648df2` で green だが、#1057 の contract を満たすにはまだ不足があります。
### Blockers
1. High: Stop/SubagentStop の forced flush contract が lock held 時に破れます。
`session_manifest_debounce.mjs --flush` は worker.lock があると `flush_skipped_lock_held` で即returnし、`session_manifest_coordinator.sh` はそのまま guard / producer に進みます。pending debounce state を flush してから Stop manifest を生成する契約を満たしていません。bounded wait / worker handoff / stale lock recovery のいずれかを入れ、lock held + pending event のテストを追加してください。
2. High: Bash read-only classifier が危険に楽観的です。
`sed` と `find` を先頭コマンドだけで read-only 扱いしているため、`sed -i ...` や `find . -delete` が producer invocation 0 になります。read-only allowlist は subcommand/flag まで見て、迷うものは `mutation_bash_unknown` として queue してください。
3. High: detached worker 内 producer に timeout がなく、hang 時に worker.lock を永久保持できます。
`spawnSync(PRODUCER_CMD, PRODUCER_ARGS, ...)` に timeout がありません。producer hang → worker lock 未解放 → future PostToolUse queue 詰まり → Stop flush skip の経路があります。producer timeout / maxBuffer / stale lock TTL / heartbeat を追加してください。
4. Medium/High: debounce state file に raw cwd を保存しています。
`artifacts/session-manifest-debounce/events/*.json` に `cwd` がそのまま残ります。#1057 は raw cwd / absolute path を残さない契約なので、event spool 自体も sanitized relative path / mutation type だけにしてください。
5. Medium: scope-rollup capture が coordinator の timeout/redaction/10行制限の外です。
capture stderr を直接 `cat` しており、noisy/hanging capture で coordinator contract を破れます。capture も `run_step` に統合してください。
### Required tests
- pending event + worker.lock held + Stop/SubagentStop flush の順序保証
- `sed -i`, `find -delete`, `git diff --output` が mutation扱いになること
- debounced producer hang で lock TTL/recovery すること
- queued event file に raw cwd / transcript_path / absolute path が残らないこと
- scope-rollup capture の noisy stderr/hang が 10行以内・redacted・exit 0 になること
現状は REQUEST_CHANGES です。Claude Code / Codex CLI に投げる修正プロンプト |
Summary
PostToolUse の session manifest hook を Claude Code native async の debounce front gate に差し替えたうえで、iteration 3 では live worker lock・mutation Bash・producer hang・event spool redaction・scope-rollup capture・hook-boundaries narrative drift まで補強しました。Stop/SubagentStop は pending debounce state の flush を優先し、完了できない場合も machine-readable timeout reason を返したまま fail-open を維持します。
Checks
.claude/hooks/session_manifest_debounce.mjsを追加.claude/settings.jsonの PostToolUse を native async + debounce entrypoint に更新docs/dev/hook-boundaries.mdと.claude/settings.jsonの topology / timeout / stderr contract / narrative を同期Schema Change Applicability
Schema Consumer Inventory
Safety Claim Matrix
安全性に関わる変更点と、今回の検証で担保した範囲・未統制の残りを表で整理します。
mutation_bash_unknownへ倒すuv run pytest .claude/hooks/tests/test_session_manifest_debounce.py -q -k "readonly_bash_skips_producer or mutating_bash_patterns_are_queued"uv run pytest .claude/hooks/tests/test_session_manifest_coordinator.py -q -k "flushes_pending_debounce_before_running_producer or reports_debounce_flush_timeout_when_worker_lock_stays_live"uv run pytest .claude/hooks/tests/test_session_manifest_debounce.py -q -k "worker_times_out_producer_and_releases_lock or flush_recovers_stale_lock_and_forces_pending_events"uv run pytest .claude/hooks/tests/test_session_manifest_debounce.py -q -k "event_spool_is_sanitized_without_raw_paths or stderr_redaction"とuv run pytest .claude/hooks/tests/test_session_manifest_coordinator.py -q -k "scope_rollup_capture_is_redacted_and_bounded"uv run pytest .claude/hooks/tests/test_generate_session_manifest_from_hook.py -q -k "hook_boundaries_sync or narrative_checker_detects_stale_posttooluse_text"とuv run python3 scripts/check_hook_boundaries.pyNotes
pnpm lintuv run pytest .claude/hooks/tests/test_generate_session_manifest_from_hook.py .claude/hooks/tests/test_session_manifest_coordinator.py .claude/hooks/tests/test_session_manifest_debounce.py -quv run --locked pytest .claude/hooks/tests/ -q --ignore=.claude/hooks/tests/test_secret_boundary_contract.pyuv run python3 scripts/check_hook_boundaries.py