Repository navigation
Codex gets gstack's skill routing hint and destructive-command check (GST-3172) - #4512
Merged
Merged
Conversation
|
😎 This pull request was merged. |
…eck through hooks.json (GST-3172) Setup on a Codex host merges two gstack hooks into ~/.codex/hooks.json next to the user's own hooks. They stay inactive until the user trusts them in Codex. Uninstall removes them, and gstack-doctor reports whether they are trusted. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
garrytan
force-pushed
the
codex-hooks-setup-routing-guard
branch
from
November 19, 2026 07:21
7728818 to
e318100
Compare
…at holds its hook helper From a standard global install, the hooks.json cleanup ran after ~/.claude/skills/gstack was deleted, so its helper was gone and gstack's Codex hook groups stayed behind pointing at missing scripts. The cleanup now runs beside the settings.json sweep, and a test runs uninstall from an installed copy. Review-Finding: p1/red-team#1 reader=red-team Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… how to remove them by hand Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
… change that moves no eval verdict Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…a symlinked hooks.json reads config.toml from the Codex home Removing gstack's group from hooks.json would move a user hook that follows it to a new position, and Codex keys trust by position, so codex exec would silently skip it. gstack now leaves the file unchanged and says how to remove its group by hand. config.toml is read from the Codex home even when hooks.json is a link into a dotfiles folder. The docs say that plain ./setup --no-team leaves the Codex hooks alone. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
capy-ai Bot
added a commit
that referenced
this pull request
Nov 19, 2026
…T-3173) (#4522) On Codex, gstack's /review can no longer end a session with a required step skipped: the end-of-session check reads Codex's own session log and sends the agent back to finish, as it already does on Claude Code. Why: Codex users got routing and the destructive-command check in #4512, but not the /review checklist, so a review could stop after the diff read with no second-model pass. To use it: run `./setup` again and trust the new hook in Codex (`/hooks`); turn it off with `GSTACK_SKILL_CONTRACTS=off`. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/specialist-batched#1 reader=testing Review-Finding: p1/specialist-batched#2 reader=testing
Merged
capy-ai Bot
added a commit
that referenced
this pull request
Nov 19, 2026
- `gstack-artifact validate` no longer passes a run.json that gstack-autoplan never wrote. (#4494) - /ship's changed-number check no longer stops on tests that only share a word with the change (#4478). (#4496) - On Capy, /ship no longer edits or comments on pull requests as you. (#4518) - The destructive-command check stops asking about scratch deletes and catches the real damage it used to miss. (#4513) - The destructive-command check reads commands more carefully, closing gaps found after the last release. (#4525) - The Codex readiness check and the second-model review now pick the same model for a custom Codex provider (GST-3089). (#4491) - gstack's Codex hooks work when your Codex folder's path has a `(`, `&` or other shell character in it. (#4528) - Uninstalling gstack keeps your own Codex hooks trusted. (#4528) - Codex hook setup matches Codex more closely. (#4528) - On Windows, setup copies the Claude Code hook code that gstack's Codex hooks import (#4528) - /review's checklist on Codex reads shell commands more carefully. (#4528) - On Codex, gstack now suggests the right skill for a prompt and stops destructive commands before they run. (#4512) - On Codex, /review is now held once when it tries to finish without its adversarial pass or its report, as it already is on Claude Code. (#4522) - On Codex, gstack's skill suggestion now names the skill the way Codex lists it. (#4523) - On Codex, gstack's suggested prompts and docs now name skills the way Codex lists them. (#4524) - /review on Codex with gpt-6.1-sol is no longer held back for a second-model pass it already ran. (#4526) - On Codex, office-hours, plan-design-review and gstack-upgrade work again when you name them. (#4510) - gstack knows when Codex is running unattended. (#4510) - Codex reviewers start with a clean context. (#4510) - Docs no longer say Codex has no hook support. (#4510) - A command whose output was cut off no longer counts as a finished read. (#4492) - A folder marked as published data can no longer hide source code or agent files from /ship's review. (#4516) - Correction to the on-by-default helper hooks entry: the hook still routes only to /review, /qa and /verify, so skills you've installed yourself aren't suggested yet. With gstack's skills it routes 14 of 60 real bug reports (was 17), and long prompts are no longer skipped. (#4505) - /sync-gbrain's read check now works when the first page in your code source is over 64 KB. (#4497) - Free-suite CI no longer fails before any test runs when Ubuntu's package mirror is slow. (#4530) - Syncing a second repo no longer makes the first one ask for /sync-gbrain again. (#4532) - gstack's helper hooks are now on by default in Claude Code, OpenClaw and Hermes, and the prompt-routing hook fires on real bug reports. (#4503) - `gstack-pregate clear --receipt` accepts a remote gate run from before a merged release when the release only regenerated a declared release output. (#4483) - The second-model review now keeps the reviewer's own result, and reports a used-up budget as a budget stop. (#4515) - When the reviewer wrote its review to the result file it was asked for, Codex then replaced that file with its short closing message ("Done, I wrote the review"), so the review was thrown away and reported as missing its markers. (#4515) - When the provider refuses the call with HTTP 402 Payment Required (usually a metering proxy that hit its allowance, or an account out of credits or quota), gstack used to record only "exit 1". (#4515) - The pre-commit /verify check now fails a check that times out, and its checks share one time budget (GST-3201). (#4527) - /ship's review collector no longer reads a reviewer's own scope list or list of passed checks as findings (GST-3201). (#4527) - Merge-queue stack tests fail when git cannot list a PR's added test files (GST-3201). (#4527) - /ship can now review results PRs that publish raw session data. (#4511) - /ship's review pass works when the checkout you ship isn't the project's default checkout. (#4507) - A second review round no longer reports done when nothing was reviewed. (#4520) - The prompt-routing hook now suggests skills you install yourself, and no longer sends ordinary bug reports to /qa (GST-3123). (#4506) - gstack's script runner and merge-queue checks now also refuse cut-off output. (#4502) - A failed second-model review reports the cause that actually stopped it, and the runner never deletes its own prompt. (#4519) - `gstack-ship-queue ready` now fills in the trial merges and the second-model trail read instead of printing lines to fill. (#4529) - Five small ship-tool fixes. (#4529) - A ruling the owner gives while a `/ship` run is open can be relayed. (#4529) - /ship no longer kills a working test run as stalled when the test command starts its workers in their own session. (#4533) - /ship no longer stops a review because the state-machine reader started its reply the way its instructions say. (#4504) - When Claude Code runs /verify right before a commit, it now gets a quick check instead of the full fix loop (GST-3150). (#4508) Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.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.
./setup --host codexnow adds gstack's skill-routing hint and destructive-command check to Codex's~/.codex/hooks.json, next to your own hooks, so Codex users get the same guardrails Claude Code users have.Codex runs a hook only after you trust it, so nothing fires until you accept gstack's hooks at Codex's startup prompt or in
/hooks;gstack-doctorshows whether you have.What changed
bin/gstack-settings-hookhas a Codex format (GSTACK_HOOKS_FORMAT=codex). It merges gstack's groups into$CODEX_HOME/hooks.jsonand keeps every user group value for value and in order (the file is re-indented as 2-space JSON on rewrite). It adds no tag keys, because Codex's schema rejects unknown keys. The result is checked against Codex's strict schema three times: on load, before the write, and on a re-read of the temp file before the rename. It refuses to write whenconfig.tomlalready declares a gstack hook under[hooks]or doesn't parse. A new read-onlytrust-statusverb reads Codex's trust entries; setup never writes trust.UserPromptSubmit) and the destructive-command check (PreToolUse) under the same off switches as Claude Code (skill_routing,destructive_guard,--no-team). It prints one line saying the hooks wait for trust, and one line recommendingcodex -c model_reasoning_effort=high(setup writes no reasoning setting). With older or missing Codex it says why and skips.hosts/codex/hooks/holds two small entries that reuse the Claude Code hooks. On Codex a$skillmention counts as an explicit skill choice, and the hint wording names Codex skills.askfrom aPreToolUsehook. In an interactive session the check denies, and the reason tells the model to stop and ask you; you can run the command yourself with!<command>, which skips hooks (confirmed live). Undercodex execit becomes a warning and the command runs. Deleting/or your home folder is denied everywhere.gstack-uninstallremoves gstack's Codex groups.gstack-doctorgets a "codex hooks" row: registered, trusted, untrusted or disabled.docs/skill-routing-and-contracts.md(new Codex row and Codex section),docs/hosts.md, and the README host table.Claude Code's hook registrations and hint wording are unchanged, and tests pin both.
Tests
test/codex-hooks.test.ts: the Codex format (merge, idempotence, user groups kept, strict schema, config.toml clash, trust-status), routing on Codex, the ask mapping in interactive and exec sessions, and the Claude Code output pin.test/codex-hooks-setup.test.ts: setup's gate, its version floor, uninstall and the doctor row.test/codex-hooks-real-codex.test.tsplus.github/workflows/codex-hooks.yml: installs@openai/[email protected]and checks that the real CLI loads the merged file and runs both the user's hook and gstack's routing hook, and that it skips untrusted hooks and a file with an unknown key. It points Codex at a dead local model endpoint, so it spends nothing.Known limits and review notes
Known limits
./setup's off switch andgstack-uninstallleavehooks.jsonunchanged and print how to delete gstack's group by hand. Uninstall can therefore leave gstack's group in place.Second-model review findings ruled below the blocking bar for this PR
setup:3193: the Windows gap above.bin/gstack-settings-hook:423: rewritinghooks.jsongoes through JavaScript numbers, so an integer above 2^53 in one of your own MCP hook inputs would be rounded. Claude Code'ssettings.jsonhas been rewritten the same way since before this PR.bin/gstack-settings-hook:383: the shared quoting helper leaves parentheses unquoted, so aCODEX_HOMEpath containing(or)gives hook commands the shell can't run. The same helper serves Claude Code's hooks, and a small fix for both follows this PR.Other review notes (not blocking)
bin/gstack-uninstall:622: when uninstall leaves gstack's Codex group in place, the reason is printed only on stderr, andhooks.jsonkeeps naming the deleted scripts until you remove the group.bin/gstack-settings-hook:430: the Codex schema check also refuses removal andtrust-statuswhen a newer Codex adds keys this copy of the schema doesn't know..github/workflows/codex-hooks.ymlruns only when the listed paths change;setup,careful/bin/check-careful.sh,hosts/claude/hooks/spawn-bin.tsand the payload fixture aren't listed.config.toml, andtrust-status's error says "refusing to mutate" although it only reads.Second-model review of the design decisions, ruled below the blocking bar for this PR (all five go into the follow-up that fixes the quoting helper)
bin/gstack-settings-hook:268: if you put your own handler inside gstack's group, the refusal message's advice to delete gstack's group would delete your handler too. Setup always gives gstack its own group.bin/gstack-settings-hook:193: gstack's copy of the Codex schema refusesdescription: null, which Codex accepts (setup then leaves the file alone), and lets a nestednullin an MCP hook input through, which Codex already rejects for the whole file.bin/gstack-settings-hook:1076:rollbackrestores your pre-write backup without re-checking it against the schema.bin/gstack-settings-hook:245: the duplicate check catches a gstack hook inconfig.tomlonly when its matcher is literallyBash; under^Bash$the check could run twice once both copies are trusted.bin/gstack-settings-hook:1181: whenCODEX_HOMEandhooks.jsonare both symlinks,gstack-doctorcan report a trusted hook as untrusted.Documentation
Status: current — the read-only audit found every doc touched by the Codex hooks change accurate, with no corrections needed.
Scope: base
ed4086e2to headd3bd5d6c, 6 commits and 24 selected committed files (nothing staged, unstaged or untracked). I checked authored docs againstsetup,bin/gstack-settings-hook,bin/gstack-doctor,bin/gstack-uninstalland.github/workflows/codex-hooks.yml.Documentation health:
README.md: current. The Codex host row says destructive commands are blocked once gstack's hooks are trusted.docs/skill-routing-and-contracts.md: current. The host table and the Codex section (trust, schema safety, removal, deny instead of ask) match the code.docs/hosts.md: current. It covers reasoning effort and the hooks.json registration.docs/uninstall.md: current. It covers both automatic and manual Codex hooks removal.docs/skills.md: current. Its safety section still accurately describes the Claude Code session hooks.changelog.d/codex-hooks-setup-routing-guard.md: reviewed only, and consistent with the docs.Coverage debt: the Codex routing hook and destructive-command check have reference and how-to coverage (
docs/skill-routing-and-contracts.md#codex), but no tutorial, anddocs/troubleshooting.mdhas no entry for the newgstack-doctorcodex hooksrow. That is a common gap, not a critical one. Consider/document-generate.Diagram drift: none; no architecture diagrams reference the changed surfaces.
Agent notes
git reset --hardwas denied with the reason and!git reset --hardran with no hooks; undercodex execthe ask became a warning (with Codex loads office-hours, plan-design-review and gstack-upgrade again, and knows when it runs unattended (GST-3161) #4510's session-kind);rm -rf ~/was denied; "Trust all and continue" wrote[hooks.state."…/hooks.json:pre_tool_use:1:0"]and doctor then read the hooks as trusted.CODEX_THREAD_ID, so session-kind can't see exec from hook context. The Codex guard entry setsCODEX_THREAD_IDfrom the payload'ssession_idbefore asking session-kind.bin/gstack-session-kindandcareful/bin/check-careful.share not edited.docs/skill-routing-and-contracts.md, resolved to this PR's row. Typecheck and 69 focused tests pass on the merged tree.test/gstack-config-defaults.test.ts"every DEFAULTS key is read by code" times out (about 7 s against a 5 s limit) on this machine on clean main b702243 too. Its corpus walk reads compiled binaries inbin/. Not caused by this PR.Approvals
Approved: yes (record r-7e9e421bc4e2). The full approval record stays private.
Plan: approved (record r-428a55160e56)
Plan check: approved (record r-428a55160e56)
Refs p1/red-team#1
REVIEW_LOOP: passes=1 blocking_found=3 deferred=0 noted=8 fixed=0 scope=frozen open=3 ledgers_read=2 dispatches=5
Gate edits: none detected (6 listed, 1 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Ruled note: bin/gstack-settings-hook:268:trail-sol#1 (a-a97a699ff7cf) at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) on the second-family decision-trail read
Ruled note: bin/gstack-settings-hook:193:trail-sol#2 (a-876bb9e741fb) at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) on the second-family decision-trail read
Ruled note: bin/gstack-settings-hook:1076:trail-sol#3 (a-f58527b4c279) at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) on the second-family decision-trail read
Ruled note: bin/gstack-settings-hook:245:trail-sol#4 (a-6ec8e8124aa4) at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) on the second-family decision-trail read
Ruled note: bin/gstack-settings-hook:1181:trail-sol#5 (a-245b2b293d2e) at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) on the second-family decision-trail read
Ruled note: setup:3193:outside-voice#1 at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T10:01:05.937Z: Windows fail-open is out of scope; Windows is minimal tier (approval a-6225f6510dcb)
Ruled note: bin/gstack-settings-hook:423:outside-voice#2 at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T10:01:05.995Z: Precision loss has been on main for Claude settings.json since before this PR and is hypothetical (approval a-7ff0d879c2e0)
Ruled note: bin/gstack-settings-hook:383:outside-voice#3 at d3bd5d6 ruled by Captain GStack Minder (GSTA-36) at 2026-11-19T10:01:06.059Z: gsQuoteCmd parentheses is in the shared helper on main since 11-17 and hits Claude too; its own fix PR for both hosts follows this one (approval a-bb4c0ce9fcea)