fix: Stop hook blocks only the run's owning session, not other sessions in the project#48
fix: Stop hook blocks only the run's owning session, not other sessions in the project#48cannt wants to merge 1 commit into
Conversation
…ns in the project
|
Warning Review limit reached
More reviews will be available in 58 minutes and 26 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Closing in favor of coordinating on #45, which already reworks |
Problem
The story-automator Stop hook is registered project-scoped, so it fires for every Claude Code session opened in that project. While a run is active (marker present, stories remaining), the hook returns
{"decision":"block"}to keep the orchestrator from stopping early — but it has no way to tell which session owns the run. So any other session in the same project gets blocked too: a second session opened to watch the run, or unrelated work in another worktree, cannot stop. The existingSTORY_AUTOMATOR_CHILDexemption only covers spawned child sessions.Fix
Record the orchestrator's own session id as
ownerSessionin the active marker at create-time (Claude Code exportsCLAUDE_CODE_SESSION_IDinto hook/CLI subprocesses). In the Stop hook, read the caller'ssession_id(Claude passes the hook payload on stdin) and only keep blocking when it matchesownerSession; any other session returns0(not blocked).Backward compatibility
Markers created before this change have no
ownerSession, so the hook falls back to the prior block behavior — no regression for in-flight runs.Changes
commands/orchestrator.py— recordownerSessionin the markercreatepayloadcommands/basic.py—cmd_stop_hookreads the callersession_idand gates on ownerTests
Added:
marker createrecordsownerSessionfromCLAUDE_CODE_SESSION_ID.(The legacy / no-
ownerSessionpath is already covered by the existingtest_stop_hook_uses_project_root_env...test, which uses an owner-less marker and asserts a block.)tests/test_stop_hooks.py→ 30/30.npm run pack:dry-run,npm run test:cli, andnpm run test:smokeall pass. Full suite → 413/414; the one failing test (test_build_cmd_uses_legacy_ai_command_consistently_for_claude) also fails on a clean checkout ofmainand is unrelated to this change.