Repository navigation
fix(T13890): bound cleo hook stop: detach session end, deadline ask-enforce - #2363
Merged
Merged
Conversation
…nforce The tick was already bounded (group SIGKILL plus stdout destroy at the deadline). What followed it was not: claude-code's spawnSync of cleo session end had no timeout, and ask-enforce was awaited without a deadline. Session end now runs detached and unawaited; ask-enforce falls back to no-block after ASK_ENFORCE_DEADLINE_MS (5 s). Tests: a tick whose setsid grandchild holds stdout returns at the deadline; a hung ask-enforce cannot hold the stop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dlines Session end is awaited for at most SESSION_END_WAIT_MS (20 s) through runBounded, then left running unref'd. A failure or an overrun prints one stderr line with the duration, and so does the ask-enforce deadline. Tick (60 s max) plus 5 s plus 20 s stays under Claude Code's 120 s Stop timeout. Test: a real slow session-end process; the stop returns at the wait with one warning; a failing one reports its exit status. Co-Authored-By: Claude Opus 5.5 <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.
cleo hook stoptook 160 s in rel-qual's smoke, past Claude Code's 120 s Stop timeout. After this PR, a Stop returns within the tick deadline (30 s by default, 60 s at most) plus at most 5 s.What I found reading the code and probing
runTickKillableSIGKILLs the whole process group at the deadline (detached: truewithprocess.kill(-pid)), destroys stdout and unrefs the child, then settles. Nothing awaitscloseorexitafter the timer fires.setsidand holds stdout returns at the deadline (2 s withCLEO_GOAL_TICK_TIMEOUT_MS=2000), for both codex and claude-code.endSessionwasspawnSync('cleo session end')with no timeout, so any slow session end (extraction, backups, a cold store) added directly to the Stop.askEnforcewas awaited with no deadline.cleo-goal/ocgmise shim exists on this machine, and a sandboxed session end took 2 s. If rel-qual's run points somewhere else, I'll follow up.Fix
endSessionnow spawnscleo session end --quietdetached withstdio: 'ignore'and unrefs it. The Stop never waits for it.askEnforceruns underASK_ENFORCE_DEADLINE_MS(5 s) through an unref'd timer. Past the deadline it counts as no block, consistent with the dispatcher's existing fail-open behaviour.Tests (
stop-dispatch-entry.test.ts)stopDispatchreturns at the 800 ms deadline withsessionEnded: true.ASK_ENFORCE_DEADLINE_MS.Verification
The owner directive is no local heavy runs, so CI runs the tests and typecheck.
--check), 25, 38, 40 and 32 (--base origin/main) pass. CI enforces gate 39.Merges are frozen for 10.20; this targets 10.21.
🤖 Generated with Claude Code