Skip to content

gstack's Codex hooks keep working with unusual folder paths and after uninstall (GST-3197) - #4528

Merged
capy-ai[bot] merged 6 commits into
mainfrom
codex-hooks-hardening
Nov 19, 2026
Merged

capy-ai[bot] merged 6 commits into
mainfrom
codex-hooks-hardening

Conversation

@garrytan

@garrytan garrytan commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

gstack's Codex hooks no longer block every prompt when your Codex folder's path has a ( or &, and uninstall keeps your own Codex hooks trusted.
Why: both broke Codex sessions; setup also now matches Codex's hook rules, and the /review checklist on Codex reads shell commands more carefully.
Nothing to do: plain paths keep the exact hook command they had, so Codex asks for no new trust.

What changed
  • Path quoting (bin/gstack-settings-hook): a hook command whose path holds any character outside [A-Za-z0-9_@%+=:,./-] (or non-ASCII) is quoted for Claude Code and Codex. Before, ( or & made a shell syntax error, which Codex reads as "block".
  • Uninstall keeps your hooks' trust positions: removing gstack's group (uninstall, prune-stale, turning a hook off) leaves {"hooks": []} where gstack's group sat, so groups after it keep the index Codex trusts them by. When your handler is inside gstack's group, gstack leaves the file alone and names the one handler to delete. gstack-uninstall prints a warning when gstack's Codex hooks are still in place.
  • Setup matches Codex's own rules: description: null is accepted, MCP hook input carrying a null is refused, rollback won't restore a backup Codex would skip, a gstack hook already declared in config.toml under any matcher that covers Bash is caught (Rust's leading (?i)/(?m)/(?s), \A and \z are translated; anything JS still can't compile is refused), and trust status keys on the same path Codex uses when CODEX_HOME is a symlink.
  • Windows: setup also copies hosts/claude/hooks into Codex's gstack folder, because the three Codex shims import it. Native Windows Codex starts hooks through cmd.exe, which can't run these Bash scripts, so this alone doesn't make them run there (see Known limits).
  • /review checklist on Codex (lib/codex-rollout.ts): quote-aware command splitting; every read-error line still drops the read unless it provably names another file (another read's path, longer path winning, or a path that is no SKILL.md); PowerShell's "Cannot find path" counts as a failed read, a last command that reads one file and exits non-zero isn't a load, a || fallback isn't a load, and an image-only user message starts a new turn.
  • Docs: the Codex paragraph in docs/uninstall.md (delete a trailing group only when it holds nothing but gstack's handlers); a changelog fragment.
Tests
  • New and rewritten tests in test/codex-hooks.test.ts, test/codex-hooks-setup.test.ts (Windows copy, uninstall slot and warning), test/skill-contract-codex.test.ts and test/codex-hooks-real-codex.test.ts (real codex-cli 0.170 hooks/list shows your group keeps its trusted key after gstack's is removed, and the hooks run from a hooks(2) path).
  • Each new or changed test fails against main's bin/, setup and lib/codex-rollout.ts, and passes here; typecheck clean.
Known limits
  • A read in the middle of an && chain (cd /nope && cat X && echo) still counts as a load, and so does a quoted echo that contains cat …SKILL.md.
  • Other hook options (timeout, statusMessage) stay stricter than Codex's own parser, except that rollback accepts a backup with "timeout": 1.0, which Codex rejects; such a backup is the user's own earlier file.
  • Native Windows Codex runs hook commands through cmd.exe, so gstack's Bash hooks don't start there.
  • A read inside a pipeline under pipefail is judged by the call's exit status.
  • A successful SKILL.md read is dropped when the skill's own text has a read-error phrase with no slash in it (such as "can't read"); no skill with a contract has such a line today.
  • Named risk (accepted in review): a Rust-only matcher class in config.toml (\pL without the u flag, [[:alpha:]]) reads as no clash, so a gstack hook also declared there under such a matcher would run twice.
  • Rewriting hooks.json round-trips it through JSON, so an integer above 2^53 in a hook's input would change; this already held for every write before this PR.
Documentation

Status: updated. One stale Codex hooks paragraph corrected; no blockers.

Scope: base 18e24a2..1c91b66 on codex-hooks-hardening (10 committed files, nothing staged, unstaged or new). I audited docs that mention Codex hooks.json or hosts/codex/hooks: docs/skill-routing-and-contracts.md, docs/uninstall.md, docs/hosts.md and changelog.d/codex-hooks-hardening.md.

Documentation health:

  • docs/skill-routing-and-contracts.md: Updated. Uninstall and --no-team now leave an empty group so your own hooks keep their Codex trust positions; gstack refuses only when your handler sits inside gstack's group. Added that native Windows Codex can't run the hooks yet.
  • docs/uninstall.md: Current (updated on the branch).
  • docs/hosts.md: Current.
  • changelog.d/codex-hooks-hardening.md: Current (reviewed only).

Coverage debt: none. The changed hook behavior is covered by the reference docs and the uninstall how-to. Path quoting is described in the changelog only; it's internal hardening with no user setting.

Diagram drift: none.

Agent notes

Bug fixes (no plan review), items 1-9 of the GST-3197 brief. Decision trail: reports/GSTA-651-decisions.tsv rows 13-38 in the controller drive. Paid evals: none for this PR (Captain's ruling: the release gate covers the paid tier at the cut).

Captain grants (GStack Minder, GSTA-36, 2026-11-19)

Pre-Landing Review: 3 issues — 2 fixed (granted), 1 skipped as a named risk, 0 deferred; fix-check: 2 notes; adversarial-native: 6 notes, none blocking.
REVIEW_LOOP: passes=1 blocking_found=0 deferred=0 noted=8 fixed=2 scope=frozen ledgers_read=3 fix_checks=1 dispatches=1 est_input_tokens=15451
Gate edits: none detected (8 listed, 2 read; patterns: RH-1,RH-3,RH-4,RH-12,RH-13,RH-14,RH-15,RH-16; unlisted idioms: none)
Exploratory QA: pass on the fixed tree (remove-source leaves an empty group and quotes a path with a space and parenthesis; the multi-file read replay now loads). The first run at 21958b5 failed probe 002, which the granted fix closed.
Noted, not fixed (below the floor): non-string matcher in config.toml throws instead of refusing; a placeholder from an earlier run is never trimmed once it ends up last; uninstall's 2>&1 hides prune-stale warnings on success; namesOneFile counts an option's value as a file and misreads bash -lc "cat X" and cat < X (a silent non-zero exit then counts as a load).
CI: Free Tests 44553074910 carried bun run test (1710 files) at 4b5de77; codex-hooks lane 76 pass; requires-remote lanes cleared from 44553074910, 44553074531 and 44553074636.

Approvals

Approved: yes (record r-40bfcc860571). The full approval record stays private.
Plan: exempt: bug fix
Plan check: exempt bug fix

{
  "schema_version": 1,
  "pr": 4528,
  "head": "4b5de770cae4b27dcfdadf2eb8ef36bd63344819",
  "version": "1.101.0.0",
  "base": "main",
  "gate": {
    "bun run test": {
      "pass": 1710,
      "fail": 0,
      "skip": 0
    },
    "codex-hooks": {
      "pass": 76,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "bun_run_test",
      "run": 44553074910,
      "attempt": 1,
      "tree": "14f58ac727cc842ea94d482443813a77c51debbb"
    }
  ],
  "calls": 41,
  "session_kind": "unattended",
  "run": "ship-4528-21958b5",
  "head_tree": "14f58ac727cc842ea94d482443813a77c51debbb",
  "product_patch_id": "8fc6f344acb0110129d554286d784e09dcc23ad8",
  "gstack_version": "1.101.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 252,
    "rules": "1afa38a4be3b5eef",
    "base": "3cccf074adb613b7fa950c5d7f8f55469be0ded7",
    "registry": "3cccf074adb613b7fa950c5d7f8f55469be0ded7",
    "gate_scan": {
      "tagged": 0,
      "head": "4b5de770cae4b27dcfdadf2eb8ef36bd63344819"
    },
    "reasons": [
      "runtime=252"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @14f58ac727cc (8 checks, current for 4b5de770cae4)",
  "requires_remote": [
    "free-tests.yml/cso-macos-launcher: https://github.com/garrytan/gstack/actions/runs/44553074910/attempts/1",
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/44553074910/attempts/1",
    "windows-setup-e2e.yml/windows-setup: https://github.com/garrytan/gstack/actions/runs/44553074531/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/44553074636/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=14f58ac727cc tests=38332 skipped=104 runs=44553074910/1 profiles=ci-reuse/free-tests heads=4b5de770cae4 verified=2026-11-19T15:32:20.600Z"
  ],
  "issues": {
    "fixes": [],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "updated",
    "scope": "docs/ (Codex hooks.json and hosts/codex/hooks mentions: skill-routing-and-contracts.md, uninstall.md, hosts.md), changelog.d/codex-hooks-hardening.md"
  },
  "review_loop": {
    "passes": 1,
    "blocking_found": 0,
    "deferred": 0,
    "noted": 8,
    "fixed": 2,
    "scope": "frozen",
    "fix_checks": 1,
    "rounds": 2,
    "est_input_tokens": 15451,
    "ledgers_read": 3,
    "dispatches": {
      "specialist-batched": 1
    }
  },
  "gate_dispositions": []
}

…ws and after uninstall (GST-3197)

Quote hook paths with shell metacharacters, keep your Codex hook groups' trust positions on uninstall, copy the Claude hook code Codex shims import on Windows, and read shell commands more carefully in the Codex /review checklist.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@trunk-io

trunk-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

…mes another file, read Rust matcher syntax, and say plainly that Windows Codex can't start the hooks yet

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai capy-ai Bot changed the title gstack's Codex hooks keep working with unusual folder paths, on Windows and after uninstall (GST-3197) gstack's Codex hooks keep working with unusual folder paths and after uninstall (GST-3197) Nov 19, 2026
garrytan and others added 3 commits November 19, 2026 14:24
A read that names more than one file no longer loses its load when another file fails; the exit-status rule applies only to a one-file read.

Review-Finding: p1/specialist-batched#1 reader=red-team
Review-Finding: lib/codex-rollout.ts:217:functional-contract reader=qa
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>
… can't run the hooks yet

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai

capy-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Flaky, not this change: test/first-use.test.ts:152 failed in free-suite (1), run 44546269116, at 09b1f52. lib/first-use.ts lists drive folders in directory order and the test expects alphabetical, which is a known defect fixed in #4530. This PR doesn't touch that file, and the test passes locally at this head. I reran the failed jobs once at the same head.

@capy-ai
capy-ai Bot merged commit 9610ba4 into main Nov 19, 2026
59 checks passed
@garrytan garrytan mentioned this pull request Nov 19, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant