Stop-review gate discards the failure reason on four paths; every failure surfaces as a DEP0190 warning
Summary
stop-review-gate-hook.mjs discards the reason a stop-time review failed, on four independent paths. In practice every failure of the gate surfaces as an unrelated Node deprecation warning, which is indistinguishable from a broken toolchain and gives the user nothing to act on.
Observed on plugin version 1.0.4, Windows 11, Node v24.
1. The stderr || stdout fallback is unreachable
const detail = String(result.stderr || result.stdout || "").trim();
codex-companion.mjs prints a DEP0190 deprecation warning to stderr on every run, including successful ones:
(node:31720) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true ...
(Use `node --trace-deprecation ...` to show where the warning was created)
So result.stderr is always truthy and || result.stdout is dead code. Meanwhile runForegroundCommand reports a failed run by writing its JSON payload to stdout and propagating the exit status, adding nothing to stderr. The real reason is therefore always on the stream this expression can never read.
Reproduction — a child that fails exactly the way the companion does:
process.emitWarning('shell option true', { type: 'DeprecationWarning', code: 'DEP0190' });
console.log(JSON.stringify({ status: 1, rawOutput: 'THE REAL REASON' }));
process.exitCode = 1;
String(r.stderr || r.stdout) yields the deprecation warning. THE REAL REASON is discarded.
2. ?? treats an empty string as present
String(payload?.error ?? payload?.rawOutput ?? "")
?? falls through only on null/undefined, so an empty error string blocks rawOutput from ever being read. And an empty rawOutput produces an empty detail, which drops the entire payload — including status and threadId, the only identifiers for the failed turn — leaving the generic "task failed" message.
Also, error may be a structured object; String(obj) renders [object Object].
3. On exit ZERO, a non-verdict answer is replaced by a label
return {
ok: false,
reason: "The stop-time Codex review task returned an unexpected answer. ..."
};
This is the branch reached when the model returns something that is neither ALLOW: nor BLOCK: — which is exactly where a refusal, an error explanation, or a truncated answer arrives. The text is thrown away, so every such failure looks identical.
The JSON.parse catch has the same shape: it reports "returned invalid JSON" and discards the bytes.
4. BLOCK keeps only its first line
const reason = firstLine.slice("BLOCK:".length).trim() || text;
The body is dropped unless the headline is empty, so the file, the reproduction, and the reasoning are lost and the user receives a one-line assertion they must re-derive.
Suggested fix
Report both streams rather than choosing between one, and never replace text with a label:
- Filter Node warning lines out of stderr, then include both the filtered stderr and the stdout payload, each labelled — so neither can suppress the other. Filtering a fixed list of warning shapes and then still preferring stderr is not sufficient: any unrecognised stderr line re-triggers the same discard.
- Treat empty strings as absent when choosing between
errorandrawOutput,JSON.stringifya non-string value, and fall back to the full payload text so the detail can never be empty while the child produced output. - Include the offending text in the "unexpected answer" and "invalid JSON" branches, bounded with an explicit truncation marker rather than dropped.
- Carry the
BLOCKbody alongside its headline.
Happy to open a PR if useful.
Note
I could not reproduce the underlying non-zero exit on demand — six controlled attempts (fresh thread, resumed thread, benign prompt, long benign, short prompt dense with shell commands, long and dense) all returned exit 0. That is a separate question from this report: whatever the cause, the gate should be able to state it.
A concrete and probably common instance of the discarded reason: quota exhaustion. When the ChatGPT account behind chatgpt auth is out of quota, codex exec exits non-zero having written nothing to stdout, and the companion records status: 1 with an empty rawOutput — byte for byte what a crashed runtime produces.
The message that gets discarded is specific and actionable:
ERROR: You've hit your usage limit. ... try again at <time>.
Combined with the missing stop_hook_active guard in #548, this blocked roughly twenty session-end attempts on 1.0.6 / macOS 15.7.7 and was diagnosed as a broker leak first, because nothing in the output distinguished "the reviewer never ran" from "the review found problems". The underlying design point, separate from the four discard paths: a gate with two outcomes cannot express "could not run", and a block that no available action can satisfy is worse than a warning.
Full write-up:
Summary
The Stop hook blocks session end when the review reports findings, which is the documented and desired behaviour. It blocks identically when the review process fails to produce any output at all. A launch failure is therefore indistinguishable from a finding, and no action available to the session can satisfy the gate: there are no findings to address, and the gate will not accept that there is nothing to address.
The clearest trigger is quota exhaustion, which is not a fault in the plugin but exposes the design gap sharply.
Environment
openai-codexClaude Code plugin 1.0.6, stop-time review gate enabled- Codex CLI 0.153.0, auth method
chatgpt - Claude Code 2.1.236, Node v26.8.1
- macOS 15.7.7 (Darwin 24.6.0)
What was observed
Six consecutive stop attempts were blocked by a review that reported status: 1 with
rawOutput: "", no touched files and no reasoning. Nothing in the hook output distinguished this
from a review with findings, and each attempt also left an orphaned broker behind (filed
separately).
The cause of at least one of those failures was an exhausted account quota. Run directly,
codex exec exits non-zero having written nothing to stdout:
ERROR: You've hit your usage limit. ... try again at 11:08 AM.
The companion records that as status: 1 with an empty rawOutput — byte for byte what a crashed
runtime produces. The same signature therefore covers at least: quota exhausted, network
unavailable, broker dead, Codex binary missing from PATH in the hook's environment.
Steps to reproduce
- Enable the stop-time review gate.
- Make the review unable to run. Exhausting quota is the realistic case; disconnecting the
network or pointing
PATHaway fromcodexreproduces the same signature. - Finish a turn and let Claude Code attempt to end the session.
The gate blocks. It keeps blocking on every subsequent attempt. Nothing in the message indicates that the reviewer never produced a verdict.
Expected
A review that could not run is reported as inconclusive and distinguished from a review with findings. Three outcomes rather than two: passed, findings, could-not-run. What to do with the third is a policy choice — fail open with a visible warning, or fail closed with the reason and the remedy named — but it must not be silently identical to a finding.
Actual
Two outcomes only. Any non-success is treated as a blocking finding, with no output that would let the session, or the operator, tell which one happened.
Impact
Three clean turns were held up on this machine, and the loop was only escaped by disabling the
gate through codex-companion.mjs setup --disable-review-gate. The gate itself is valuable — over
one evening it produced fourteen legitimate findings and no false ones — so operators who hit this
end up turning off a useful check for a reason unrelated to code quality.
Suggested fix
- Classify the review result. On a non-zero exit with empty output, report "the review could not run" with the captured stderr, and treat it under an explicit policy rather than as a finding.
- Surface the underlying error. The quota message quoted above is specific and actionable, and it was discarded before reaching the operator.
- Consider not blocking on a result that carries no findings to act on. A gate that cannot be satisfied by any available action is worse than one that warns and lets the session close.