Support Codex hooks feature rename and prevent nested Stop hook recursion#204
Closed
shallwe16623 wants to merge 1 commit into
Closed
Support Codex hooks feature rename and prevent nested Stop hook recursion#204shallwe16623 wants to merge 1 commit into
shallwe16623 wants to merge 1 commit into
Conversation
Author
|
Thanks! I noticed after opening this that related fixes already landed on dev in #134 and #194. This PR was based on main because main still hard-codes codex_hooks in the Codex install/runtime paths. If the expected flow is to merge dev into main, feel free to close this as superseded. If a smaller main backport is useful, I can adjust this PR to match the existing dev implementation more closely |
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
This updates the Codex integration to support the current native hooks feature name,
hooks, while retaining compatibility with older Codex builds that exposecodex_hooks.The main behavioral fix is that nested Codex reviewer/helper invocations now disable the active hooks feature. This prevents Humanize's Codex Stop hook from recursively triggering itself when it launches
codex revieworcodex exec.Problem
Current Codex builds expose lifecycle hooks as the stable
hooksfeature:Codex docs also describe
hooksas the canonical feature key andcodex_hooksas a deprecated alias.Humanize still assumed
codex_hooksin several Codex paths:codex review/codex execcallscodex execcallsThat creates two failure modes on current Codex builds:
codex_hooks.--disable codex_hookseven though the active feature ishooks. In that case, Stop hooks are not disabled for the nested Codex process, so the nested reviewer/helper can trigger the same Stop hook again when it exits.Root Cause
The feature was renamed from the older
codex_hookskey to the canonicalhookskey. The install/runtime scripts did not consistently detect which feature name the installed Codex CLI exposes, and some paths hard-codedcodex_hooks.There was also a related shell robustness issue: several probes used
command | grep -qunderset -o pipefail. Whengrep -qexits early after finding a match, the producer can receiveSIGPIPE, causing the whole pipeline to look like a failed probe. This can make supported Codex flags/features appear unsupported.Changes
hooksfirst and fall back tocodex_hookswhen installing Codex hooks.codex_hooks.codex reviewandcodex execcalls.grep -qinpipefailpipelines for Codex feature/help probes by capturing command output first.hooksoutput and assert nested calls use--disable hooks.Compatibility
This keeps older Codex compatibility by falling back to
codex_hookswhenhooksis not present incodex features list.Validation
bash -n scripts/install-codex-hooks.sh hooks/loop-codex-stop-hook.sh scripts/bitlesson-select.sh tests/test-codex-hook-install.sh tests/test-disable-nested-codex-hooks.sh tests/test-bitlesson-select-routing.shbash tests/test-codex-hook-install.shbash tests/test-disable-nested-codex-hooks.shbash tests/test-bitlesson-select-routing.sh