fix: harden codex helper scripts (prompt substitution, state keys, preflight)#3
Open
cdgraham wants to merge 1 commit into
Open
fix: harden codex helper scripts (prompt substitution, state keys, preflight)#3cdgraham wants to merge 1 commit into
cdgraham wants to merge 1 commit into
Conversation
…eflight) - load_prompt: replace awk gsub with quoted bash substitution — values containing '&' or backslashes (implementer notes, paths) were mangled; unquoted bash patsub has the same '&' bug on bash >= 5.2 - target_key: append cksum of resolved target so distinct targets that sanitize identically no longer share thread/review state (key format change: in-flight sessions from older versions need a fresh start.sh) - require_tools preflight in start/resume: missing jq previously killed start.sh silently (set -e + suppressed stderr) after the Codex call - resume.sh: fail cleanly on empty thread file instead of invoking 'codex exec resume ""' - model selection: match */codex-implement/state exactly, not glob *codex-implement* which a repo path could accidentally satisfy - codex-implement: ship state/.gitignore like the review skills so reports/event logs can't be committed in target repos - README: caveat that implementer --notes are injected into the reviewer prompt and can steer it Co-Authored-By: Claude Fable 5 <noreply@anthropic.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.
While reviewing the codex helper scripts for security/bug issues, I found a few real defects and hardened them. All changes are in the shared script layer (
codex-plan-review/scripts/) plus one new file forcodex-implement.Fixes
1.
load_promptcorrupted values containing&or backslashes (confirmed bug)awk's
gsub()treats&in the replacement as "the matched text", so implementer notes likeFixed X & Yrendered into the reviewer prompt asFixed X {{IMPLEMENTER_NOTES}} Y, andawk -vescape processing mangled backslashes (C:\Users,\nin notes). Since--notesis free-form prose written every resume round, this hits real usage.Rewrote substitution in bash with quoted replacement expansions:
${content//'{{TARGET}}'/"${TARGET-}"}. The quoting matters — unquoted bash patsub has the exact same&bug on bash ≥ 5.2 (patsub_replacementis on by default there). Verified against hostile inputs (&, backslashes,$, multiline) on bash 5.2.2.
target_keycollisionsfoo/barandfoo__bar(orrelease?1/release_1) sanitized to the same key and silently shared one Codex thread + review file. The key now appends acksumof the resolved target; same file via different relative paths still maps to one key.reset.sh/start.shfresh after upgrading. State is disposable session data, so nothing is lost beyond thread continuity.3. Missing
jqkilledstart.shsilentlyjq's stderr was redirected to/dev/null, so withset -ea missingjqaborted the script with no message at all — after the Codex call already ran, orphaning the session. Added arequire_toolspreflight (codex jqin start,codexin resume) that fails loudly up front.4. Empty thread file produced a confusing failure
An empty
.threadfile passed the-fcheck and invokedcodex exec resume "".resume.shnow exits 2 with a "run reset.sh, then start.sh" hint.5. Model selection glob could misfire
case "$STATE_DIR" in *codex-implement*)matches anywhere in the path — a repo checked out at e.g.~/work/codex-implement-fork/would run all review threads on the implementation model. Now matches the trailing*/codex-implement/statecomponents exactly.6.
codex-implementshipped nostate/.gitignoreBoth review skills ship one precisely so thread ids, reports, and raw JSONL event logs (which embed prompts and chunks of the user's codebase) never get committed in target repos, but the implement skill's
state/is created at runtime unignored. Added the same.gitignore.README
Added a short caveat to the Multi-Agent section: implementer
--notesare injected verbatim into the reviewer's prompt and can steer it — worth knowing when a review converges suspiciously fast.Verification
bash -non all scripts; functionally exercisedload_prompt(hostile/multiline values),target_key(collision + path-stability cases),require_tools, model selection for both state paths, and theshow.sh/reset.sh/resume.shflows against a scratch state dir.🤖 Generated with Claude Code