Skip to content

/codex cleanup stops asking for /careful approval, and plan-mode Codex reviews start again - #4851

Merged
capy-ai[bot] merged 4 commits into
mainfrom
fix-codex-prompt-cleanup-plan-mode-prompt-file
Nov 26, 2026
Merged

capy-ai[bot] merged 4 commits into
mainfrom
fix-codex-prompt-cleanup-plan-mode-prompt-file

Conversation

@garrytan

@garrytan garrytan commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

/codex challenge and /codex consult no longer stop for a /careful delete warning on every run, and the Codex second-model review in /plan-eng-review and /plan-ceo-review works in Claude Code plan mode again.
Why: both broke a core review path on every use; the reports came from @dmfrede and @mcp10.
Nothing to do after merge.

What changed

/careful no longer asks about the /codex cleanup, and the plan-review prompt file moves into the project

/careful no longer asks about the /codex cleanup, and the plan-review prompt file moves into the project.

Before/after as text: /careful no longer asks about the /codex cleanup, and the plan-review prompt file moves into the project
--- Before · before.txt · captured output
+++ After · after.txt · captured output
+$ /codex consult cleanup, as the /careful hook sees it (this PR)
-$ /codex consult cleanup, as the /careful hook sees it (main)
 PROMPT_FILE="$_REPO_ROOT/.gstack/tmp/codex-prompt.AbC123"
+rm -f "${PROMPT_FILE:?}"
-rm -f "$PROMPT_FILE"
 
 /careful:
+{}
+(allowed, no prompt)
-ask: [careful] Destructive: deletes files outside this session's folder, or through a variable that may be empty.
 
+$ plan review prompt file (this PR)
+[ ! -L .gstack -a ! -L .gstack/tmp ] && mkdir -p -m700 .gstack/tmp && mktemp "$PWD/.gstack/tmp/gstack-plan-prompt.XXXXXX"
+the file lands inside the project, where plan mode lets Write reach it
-$ plan review prompt file (main)
-umask 077; mktemp "${TMPDIR:-/tmp}/gstack-plan-prompt.XXXXXXXX"
-Claude Code plan mode: Write to $TMPDIR is refused, so Codex never starts
 

"Every /codex challenge run stops for a /careful approval at cleanup" (#4841): the cleanup deleted the prompt with rm -f "$PROMPT_FILE", a variable /careful cannot resolve, so it asked every time. The cleanup now reads "${PROMPT_FILE:?}", which /careful already accepts as guarded. The hook itself is unchanged.

"The Codex outside voice fails in plan mode" (#4842): the plan reviews created the prompt under $TMPDIR, where plan mode refuses Write, so Codex never ran. The prompt now goes to .gstack/tmp/ inside the project (folder mode 700, file mode 600). The command refuses a .gstack or .gstack/tmp that is a symlink, so a cloned repo cannot redirect the prompt. Cleanup is a plain rm -- '<path>', which /careful allows.

Why

People reported that /codex stopped for approval on every run and that the plan-review second opinion never started in plan mode. Now /codex runs straight through under /careful, and plan-mode reviews get their second-model review again.

Blast radius

The change touches the generated /codex, /plan-eng-review and /plan-ceo-review skill files for every host, and nothing else reads these lines. The /careful hook is unchanged: the new test feeds the generated lines to careful/bin/check-careful.sh and runs the generated create and cleanup commands in a scratch repo (script ran).

Documentation

Status: current. No documentation changes were needed for this branch.

Scope: committed diff 8982588..254b65f (12 files: the /codex challenge and consult templates and their generated files, the /plan-ceo-review and /plan-eng-review sections, the outside-voice resolvers, tests and one changelog fragment). Nothing staged, unstaged or untracked. Searched README, ARCHITECTURE, CONTRIBUTING, docs/ and authored templates for the old prompt-file and cleanup wording.

Documentation health:

  • README.md: Current
  • ARCHITECTURE.md: Current
  • CONTRIBUTING.md: Current (its plan-mode note is unaffected)
  • docs/troubleshooting.md: Current (already calls .gstack/tmp/ gstack's scratch folder)
  • docs/skills.md: Current
  • CHANGELOG.md: Current (the changelog fragment describes both fixes accurately)
  • TODOS.md: Current

Coverage debt: none new. The changes are internal to skill prose (where the Codex prompt file lives and how it is deleted) and add no public command, flag or setting.

Diagram drift: none.

Note: docs/designs/SEVERE_FIX_WAVE_2026_10.md (a dated design record) describes a lint that wants a ${TMPDIR:-/tmp} template on mktemp; the new plan-prompt path uses $PWD/.gstack/tmp/ instead. The record was left as written.

Tests
  • bun test test/outside-prompt-file.test.ts (new, 4 cases, all fail on main): pass
  • Targeted set of 38 files: 900 pass, 1 skip, 0 fail; after the last fix, 7 focused files: 64 pass, 0 fail
  • bun run typecheck: 0 errors; bun run typecheck:test: none new
  • CI at 254b65f: every check passed (free tests ran 1724, run 45861528676)
Pre-Landing Review

Three review passes and an adversarial read. One blocking finding (writing the prompt through a symlink committed in the repo) was fixed by refusing a symlinked .gstack or .gstack/tmp. The rest are below the blocking floor and are listed in the review notes. Second-model review: not run for this change; the adversarial read ran in the same model.

Review notes

Below the blocking floor (advisory, informational, test-gap or wording items); recorded here and not fixed in this PR.

  • INFORMATIONAL sf-171f8476ad01 security finding, details recorded privately
  • INFORMATIONAL test/outside-prompt-file.test.ts:84 git-status-empty assertion dropped with the .gitignore step.
  • INFORMATIONAL sf-6f2c363d68db security finding, details recorded privately
  • INFORMATIONAL sf-41cba996e220 security finding, details recorded privately
Issues

Fixes #4841
Fixes #4842

Agent notes

Thread GSTA-873 for GST-4009. Local: targeted tests, typecheck, typecheck:test and parity-suite only; the full suite ran in CI (R65).

REVIEW_LOOP: passes=3 blocking_found=1 deferred=0 noted=10 fixed=1 scope=frozen dispatches=4

APPROVALS_RENDER: redacted (repository visibility public); gstack-approvals list shows the full record

Approvals

No approvals recorded for branch fix-codex-prompt-cleanup-plan-mode-prompt-file.
Plan: exempt: bug fix with a failing-first test (R65)
Plan check: exempt bug fix

Refs GST-4009

🤖 Generated with Claude Code

{
  "schema_version": 1,
  "pr": 4851,
  "head": "254b65fc977fce752aab2a996c2f01cba601e224",
  "version": "1.104.0.0",
  "base": "main",
  "gate": {
    "free": {
      "pass": 1724,
      "fail": 0,
      "skip": 0
    }
  },
  "ci_carried": [
    {
      "lane": "free",
      "run": 45861528676,
      "attempt": 1,
      "tree": "2c4c0408217f17bc6f904c6103114a2409766fc9"
    }
  ],
  "session_kind": "unattended",
  "run": "/home/user/.capy/work/gstack/ship-4851",
  "head_tree": "2c4c0408217f17bc6f904c6103114a2409766fc9",
  "product_patch_id": "7879f9d30a4e70ff10bc90bd4cba71198d311de4",
  "gstack_version": "1.104.0.0",
  "review_depth": {
    "depth": "light",
    "class": "code",
    "runtime_lines": 15,
    "rules": "33831f8248a814fd",
    "base": "aa503e29f4e620a2ab689172c7fb261c7b280874",
    "registry": "aa503e29f4e620a2ab689172c7fb261c7b280874",
    "gate_scan": {
      "tagged": 0,
      "head": "254b65fc977fce752aab2a996c2f01cba601e224"
    },
    "reasons": [
      "runtime=15"
    ],
    "risk": [],
    "mode": "panel"
  },
  "pregate": "requires-remote cleared @2c4c0408217f (8 checks, current for 254b65fc977f)",
  "requires_remote": [
    "free-tests.yml/macos-named-regressions: https://github.com/garrytan/gstack/actions/runs/45861528676/attempts/1",
    "windows-smoke.yml/windows-smoke: https://github.com/garrytan/gstack/actions/runs/45861528617/attempts/1",
    "pregate.json/remote_gate: remote-gate tree=2c4c0408217f tests=38499 skipped=103 runs=45861528676/1 profiles=ci-reuse/free-tests heads=254b65fc977f base_moved=aa503e29f4e6 verified=2026-11-26T16:54:54.000Z"
  ],
  "issues": {
    "fixes": [
      4841,
      4842
    ],
    "refs": [],
    "flakes": []
  },
  "docs": {
    "status": "current",
    "scope": "README.md and docs/ (plus ARCHITECTURE.md, CONTRIBUTING.md read by the audit)"
  },
  "review_loop": {
    "passes": 3,
    "blocking_found": 1,
    "deferred": 0,
    "noted": 10,
    "fixed": 1,
    "scope": "frozen",
    "rounds": 3,
    "dispatches": {
      "specialist": 3,
      "red-team": 1
    }
  },
  "gate_dispositions": []
}
{"head":"72285e5cf4a8c5f41c3e74886cecdd7d259ae601","run":"ship-4851","status":"started","review_loop":{"passes":2,"blocking_found":1,"deferred":0,"noted":4,"fixed":1,"scope":"frozen","rounds":2,"dispatches":{"specialist":2,"red-team":1}}}

…views can write their prompt

The /codex challenge and consult cleanup now deletes the prompt through a guarded variable, and /plan-eng-review and /plan-ceo-review create their Codex prompt in the project's .gstack/tmp/ instead of $TMPDIR, where plan mode refuses Write. Fixes #4841, fixes #4842.

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

trunk-io Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

garrytan and others added 3 commits November 26, 2026 16:34
…the run header and size pins unchanged

A second review found that writing a .gitignore inside .gstack/tmp could follow a committed symlink. The command no longer writes one, refuses a symlinked .gstack or .gstack/tmp, and the plan prose keeps its exact length.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
The prompt-file fix itself is in a08e4a2; this commit records which review finding it answers.

Review-Finding: p1/specialist-batched#1 reader=security
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…s it as a plain folder create

mkdir -pm700 hid the -p flag from the guard that rejects mkdir used as a lock. The command now reads mkdir -p -m700 and folds the two symlink checks into one test, which keeps the plan prose 2 characters under main.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@capy-ai
capy-ai Bot merged commit be64b10 into main Nov 26, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant