Skip to content

feat: Stop hook enforces kaizen reflection before session end (kaizen #312)#253

Merged
aviadr1 merged 1 commit intomainfrom
fix/stop-enforce-kaizen-reflection
Mar 21, 2026
Merged

feat: Stop hook enforces kaizen reflection before session end (kaizen #312)#253
aviadr1 merged 1 commit intomainfrom
fix/stop-enforce-kaizen-reflection

Conversation

@aviadr1
Copy link
Copy Markdown

@aviadr1 aviadr1 commented Mar 21, 2026

Summary

  • New enforce-kaizen-stop.sh Stop hook blocks session end when a kaizen reflection gate (needs_pr_kaizen) is pending
  • Closes the gap where agents could create PRs and stop without reflecting
  • 10 tests covering all edge cases (branch scoping, staleness, multi-PR, legacy)

Root 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

  • New hook: enforce-kaizen-stop.sh — checks for needs_pr_kaizen state using branch-scoped lookup
  • Settings: Registered in Stop hook chain (before verify-before-stop.sh)
  • Tests: 10 tests in test-enforce-kaizen-stop.sh

Test plan

  • 10 new tests pass (stop blocked/allowed scenarios)
  • 64 interaction matrix tests pass
  • All hook test suites pass

Closes Garsson-io/kaizen#312

Run tag: batch-260321-1108-3ef8/run-2

🤖 Generated with Claude Code

…(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>
@aviadr1 aviadr1 enabled auto-merge (squash) March 21, 2026 09:54
@aviadr1 aviadr1 merged commit b4317af into main Mar 21, 2026
3 checks passed
@aviadr1 aviadr1 added the overnight-dent Created by overnight-dent batch automation label Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

overnight-dent Created by overnight-dent batch automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[L2] Stop hook should enforce kaizen reflection for kaizen-linked cases

1 participant