feat: Stop hook enforces kaizen reflection before session end (kaizen #312)#253
Merged
feat: Stop hook enforces kaizen reflection before session end (kaizen #312)#253
Conversation
…(kaizen qwibitai#312) Adds enforce-kaizen-stop.sh to the Stop hook chain. This closes the gap where an agent could create a PR and stop without submitting a KAIZEN_IMPEDIMENTS reflection. The existing PreToolUse gate (enforce-pr-kaizen.sh) blocks commands, but the agent could still stop and end the session, losing the reflection. - Uses branch-scoped state lookup (prevents cross-worktree contamination) - Shows all pending PRs when multiple gates are active - Respects staleness and legacy state file rules - 10 tests covering all edge cases Run tag: batch-260321-1108-3ef8/run-2 Closes Garsson-io/kaizen#312 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
enforce-kaizen-stop.shStop hook blocks session end when a kaizen reflection gate (needs_pr_kaizen) is pendingRoot Cause
The PreToolUse gate (
enforce-pr-kaizen.sh) blocks non-kaizen commands, but agents could end sessions without calling any tools — bypassing reflection entirely. Stop hooks run on session end regardless of tool use.Changes
enforce-kaizen-stop.sh— checks forneeds_pr_kaizenstate using branch-scoped lookupverify-before-stop.sh)test-enforce-kaizen-stop.shTest plan
Closes Garsson-io/kaizen#312
Run tag: batch-260321-1108-3ef8/run-2
🤖 Generated with Claude Code