Skip to content

fix(agentic-ai): complete Codex hook deployment - #71

Merged
ulises-c merged 11 commits into
mainfrom
fix/codex-hook-deployment
Aug 31, 2026
Merged

ulises-c merged 11 commits into
mainfrom
fix/codex-hook-deployment

Conversation

@ulises-c

@ulises-c ulises-c commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • deploy and idempotently register shared hooks for Codex without replacing Railguard or unrelated hooks
  • handle Codex apply_patch payloads in command, write, ShellCheck, and test-runner hooks while preserving Claude payload support
  • keep Linux pipx dry-runs side-effect free
  • add a deterministic TAP benchmark for installed and development Railguard binaries
  • merged main back in (skills/output-styles deployment from feat(skills): add double-blind-review skill + skill symlinking #72/docs(agentic-ai): sync railguard blurb, trim fence path comment #73); one conflict in validate.sh, both sections kept
  • fix: seed ~/.codex/hooks.json and create ~/.claude on fresh installs (both aborted install.sh before)
  • fix: benchmark runs Railguard under a bench-local $HOME so Railguard's self-integrity check can't fail cases based on the live machine's Codex config
  • docs: Codex gates registered hooks behind per-hook trust (interactive) — codex exec silently skips them until trusted; --dangerously-bypass-hook-trust documented for non-interactive verification

Testing

Benchmark & repo checks

  • Codex hook benchmark: 11/11 against the development Railguard binary (railguard PR#43, which adds hook --client); installed railguard 0.5.1 predates the flag, so its 4 Railguard cases fail until railguard#43 merges — the 7 custom-hook cases pass either way
  • validate.sh exit 0; pytest 4 passed; validate-packages 107 entries; dryrun-smoke all four platforms; pre-commit clean on every PR-touched file

Fresh-install matrix (disposable fake HOMEs, 23/23)

  • fresh HOME: install exits 0, hooks.json valid, all 5 managed hooks registered exactly once, validate.sh passes
  • rerun: idempotent (byte-identical hooks.json, no spurious backup)
  • pre-existing hooks.json with railguard + user hooks: all preserved, managed hooks merged once, backup taken, stable across reruns

Live end-to-end (real codex-cli 0.150.1 sessions, isolated CODEX_HOME, --dangerously-bypass-hook-trust)

  • validate-bash.sh blocked git add -A in-session with reason surfaced to the model
  • validate-write.sh blocked an apply_patch write to /etc/... ; file not created
  • post-edit-shellcheck.sh caught SC2168 in an apply_patch'd script and fed it back
  • patch-syntax text inside a plain Bash command passed (no false positive)
  • clean apply_patch write passed all hooks

Known behavior gate: without persisted per-hook trust (or the bypass flag), codex exec runs registered hooks not at all — documented in README.

ulises-c and others added 11 commits July 31, 2026 16:07
Single content conflict in agentic-ai/Claude/validate.sh: branch added the
Codex hook registration section, upstream (#72/#73) added skills and
output-styles checks at the same insertion point. Both are disjoint intents;
kept both, Codex registration first to stay adjacent to the Hooks section.

install.sh and README.md auto-merged cleanly: upstream's skills/output-styles
deployment coexists with the branch's Codex hooks.json registration; re-read
both for prose contradictions and found none.
Codex only creates hooks.json once the user configures hooks, so on a
machine that has never done so, jq aborted install.sh (set -e) before hook
registration and the final settings.json redeploy. Seed an empty object
first; the existing jq program already handles {} correctly.

Found by running the merged install.sh + validate.sh end to end: validate
reported all five Codex hook symlinks present but hooks.json missing.
Railguard's self-integrity check reads $HOME/.codex/hooks.json and denies
every call when that file has hooks but no railguard entry — exactly the
state install.sh leaves on a machine where railguard skipped Codex
registration. The benchmark then failed 2 cases for reasons unrelated to
the code under test. Run railguard with HOME pointed at a bench-local home
carrying a minimal railguard-registered hooks.json.
On a HOME that has never run Claude Code, cp aborted install.sh at the
first deploy step. Found by exercising install.sh in a disposable fake
HOME.
Live end-to-end testing showed registered hooks are silently skipped by
codex exec until Codex records per-hook trust in config.toml (granted
interactively). Document the caveat and the
--dangerously-bypass-hook-trust escape hatch for non-interactive
verification of self-authored hooks.
@ulises-c
ulises-c merged commit 90ad4fe into main Aug 31, 2026
7 checks passed
@ulises-c
ulises-c deleted the fix/codex-hook-deployment branch August 31, 2026 21:05
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