Repository navigation
fix(agent): address review feedback on project hooks system - #119
Conversation
Addresses review feedback on #117 (project hooks system). - Kill the timed-out hook child instead of detaching it: set kill_on_drop(true) so dropping the wait future on timeout sends SIGKILL, removing the orphaned-process bug in run_hook. - Pre-tool spawn failures now block the tool call (a missing or non-executable hook binary is a misconfiguration, not flakiness). Post-tool spawn failures stay warnings since the tool already ran. - Use records.last_mut() instead of a records_before index when folding hook injections into the tool record. - Collapse multi-line doc/comment blocks to single WHY lines per the project comment policy. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Code ReviewOverviewThis PR addresses review feedback on #117 (project hooks system) with four targeted fixes: orphan-process prevention on timeout, pre-tool spawn failure now blocking, a minor index simplification, and comment reduction. The changes are focused and well-reasoned. What's Good
Concerns1.
|
Addresses review feedback on #117 (project hooks system).
Fixes
Kill orphaned child process on timeout (blocking).
run_hookpreviouslyrelied on
tokio::time::timeout(...wait_with_output()); on timeout theChildwas dropped and tokio detached the OS process, orphaning it. SetCommand::kill_on_drop(true)so dropping the wait future on timeout sendsSIGKILL — no orphaned process remains.
Note: used
kill_on_drop(true)rather than the literalselect!/child.kill().awaitfrom the issue becausewait_with_output()consumes thechild, so the literal snippet does not compile.
kill_on_dropis theidiomatic fix for this exact bug and satisfies the no-orphan requirement
while preserving
wait_with_output's concurrent pipe draining.Pre-tool spawn failure now blocks. A pre-tool hook that fails to spawn
(missing or non-executable binary) is a misconfiguration, not flakiness, so
it now returns
PreToolOutcome::Block(...)instead of silently continuing.Post-tool spawn failures remain warnings — the tool already ran. Added a
pre_tool_spawn_failure_blockstest.Use
records.last_mut(). Replaced therecords_beforeindex withrecords.last_mut()when folding hook injections into the tool record, andremoved the now-unused
records_beforebinding.Comment hygiene. Collapsed multi-line doc/comment blocks (module doc in
project_hooks.rs,drain_hook_injectionsinhook.rs, and thehooks-related comments in
tools.rs) to single WHY lines per the projectcomment policy.
Verification
cargo build -p tenex-agentpasses.cargo test -p tenex-agentpasses (including the new test).🤖 Generated with Claude Code